in reply to Re^2: Using a Hash Variable in an If Statement
in thread Using a Hash Variable in an If Statement

The first part is saying "check each line of the file (assigned to DATA, in your case rat_event) and if the line is equal to mcp, skip it (would skip 20131201.06372602.mcp and 20131202.02185602.mcp). Else chomp the line (remove new line and carriage return) and split the line into 2 variables (s and n, since no character is specified for the split it defaults to a space which would give you the station name and the time) and once it has those variables assigned it puts the values into the hash %data so s => 'n'.

Yes you should load the file first as your code is shown

open my $fh, "<rat_event" or die "Failed to open:$!"; while(<$fh>) { #do something }

Replies are listed 'Best First'.
Re^4: Using a Hash Variable in an If Statement
by Bama_Perl (Acolyte) on May 11, 2015 at 20:36 UTC
    Thank you for the response, edimusrex. That makes a lot of sense now!