in reply to Lost hash values

FWIW, your script works fine for me.

I noticed that your printout does not match what your script is doing. For example, in your code, the print out should have the word "is", but this is not what the output shows; and the code prints a newline after "ms", but this does not show in the output. It would help to see the code that actually produces the output.

the lowliest monk

Replies are listed 'Best First'.
Lost hash values
by stephen_isa (Initiate) on May 17, 2005 at 17:20 UTC
    My previous replies were hidden. One has to click on the 2nd "reply4" in this thread and then reply7 to see the fix: BTW, I am new to this posting, how to aviod this? Anyway, here is the final script:
    #!/usr/bin/perl -w open FILE1,"out.prod1" or die "Cannot open file $!"; @rec=<FILE1>; $first=undef; %save=(); foreach $x (@rec){ chomp $x; if ( $x =~ /2005/ ){ $first=$x; if(!defined $save{$first}){ $save{$first}=undef;} } if ( $x =~ /time/ ){ $lat=$x; $lat =~ s/.*?time=(\d+)\.\sms$/$1/; if( $lat > "10" ){ $save{$first}=$lat; } } } foreach $first (sort keys %save){ if ($save{$first}){ print "$first $save{$first}\n"; } }