Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Using a Hash Variable in an If Statementby Bama_Perl (Acolyte) |
on May 11, 2015 at 19:20 UTC ( [id://1126335]=perlquestion: print w/replies, xml ) | Need Help?? |
Bama_Perl has asked for the wisdom of the Perl Monks concerning the following question: Hi Monks, I have a question regarding the use of a hash. The goal of the following script is to loop through a file that looks like this:
Which is repeated >100 times. I am using a hash, because I first want to assign each string (DONT, MICH, etc) a number, which I have done so here in this hash:
What I want to do is loop through the above file (which is the format above), and for each station (DONT, MICH, etc), print out the respective number (time). However, I am unsure how to do this in an if-statement. What I have is below: where rat_event is the file I'm looping through, $station and $delaytime are the values from above, but when it comes to the 'if' statement, I'm unsure how to use the hash to output something like: Any help would be appreciated. Thanks!
Back to
Seekers of Perl Wisdom
|
|