I
ifiaz
Problem:
I populate a hash %Fnd with the following data
it loops through the file with 300000 lines of data.
###CODE
while (<>) {
if ( something == somethingelse) {
$Fnd{$Lic}{Count}++;
$cF = $Fnd{$Lic}{Count};
$Fnd{$Lic}{$cF}{ScanTimeDt} = substr($mScanTimeDt, 6, 2);
$Fnd{$Lic}{$cF}{ScanTime} = $ScanTime; #090000 (Sample Data)
$Fnd{$Lic}{$cF}{mFullScanTime} = $mFullScanTime; #20030317090000 (Sample data)
$Fnd{$Lic}{$cF}{IUMethod} = $IUMethod;
$Fnd{$Lic}{$cF}{IU} = $IU;
$Fnd{$Lic}{$cF}{Carrier} = $Carrier;
$Fnd{$Lic}{$cF}{CarCode} = $CarCode;
$Fnd{$Lic}{$cF}{FlightNo} = $FlightNo;
$Fnd{$Lic}{$cF}{Chute} = $Chute;
$Fnd{$Lic}{$cF}{TiltTimeDt} = substr($mTiltTimeDt, 6, 2);
$Fnd{$Lic}{$cF}{mTiltTimeDy} = $mTiltTimeDy;
$Fnd{$Lic}{$cF}{mTiltTime} = $mTiltTime;
$Fnd{$Lic}{$cF}{TStamp} = $TStamp;
}
}
###Looping through files end here.
## After the %Fnd is populated, I do a display of
## it in the appropriate format.
foreach $tmpLic (sort keys %Fnd) {
# do a display of the %Fnd hash one by one
}
__END__
Initially above loop was used to display, but later I
realize that I need to sort the hash not by the $Lic
in $Fnd{$Lic} but by the $Fnd{$Lic}{$Cf}{mFullScanTime}.
How can I have the hash sorted by my requirement?
I have tried various ways from newsgroups examples, etc.
but eventually fail. Could someone please help with
layman terms?
I am able to sort the hash when it is just one or two
dimensions but not more. I get utterly confused when
the gets more than two dimension.
I am newbie to perl actually to programming itself.
Thanks.
I populate a hash %Fnd with the following data
it loops through the file with 300000 lines of data.
###CODE
while (<>) {
if ( something == somethingelse) {
$Fnd{$Lic}{Count}++;
$cF = $Fnd{$Lic}{Count};
$Fnd{$Lic}{$cF}{ScanTimeDt} = substr($mScanTimeDt, 6, 2);
$Fnd{$Lic}{$cF}{ScanTime} = $ScanTime; #090000 (Sample Data)
$Fnd{$Lic}{$cF}{mFullScanTime} = $mFullScanTime; #20030317090000 (Sample data)
$Fnd{$Lic}{$cF}{IUMethod} = $IUMethod;
$Fnd{$Lic}{$cF}{IU} = $IU;
$Fnd{$Lic}{$cF}{Carrier} = $Carrier;
$Fnd{$Lic}{$cF}{CarCode} = $CarCode;
$Fnd{$Lic}{$cF}{FlightNo} = $FlightNo;
$Fnd{$Lic}{$cF}{Chute} = $Chute;
$Fnd{$Lic}{$cF}{TiltTimeDt} = substr($mTiltTimeDt, 6, 2);
$Fnd{$Lic}{$cF}{mTiltTimeDy} = $mTiltTimeDy;
$Fnd{$Lic}{$cF}{mTiltTime} = $mTiltTime;
$Fnd{$Lic}{$cF}{TStamp} = $TStamp;
}
}
###Looping through files end here.
## After the %Fnd is populated, I do a display of
## it in the appropriate format.
foreach $tmpLic (sort keys %Fnd) {
# do a display of the %Fnd hash one by one
}
__END__
Initially above loop was used to display, but later I
realize that I need to sort the hash not by the $Lic
in $Fnd{$Lic} but by the $Fnd{$Lic}{$Cf}{mFullScanTime}.
How can I have the hash sorted by my requirement?
I have tried various ways from newsgroups examples, etc.
but eventually fail. Could someone please help with
layman terms?
I am able to sort the hash when it is just one or two
dimensions but not more. I get utterly confused when
the gets more than two dimension.
I am newbie to perl actually to programming itself.
Thanks.