in reply to If Exists in an Array?
use strict; use Data::Dump qw/dump/; my %loco_data = <DATA>; print dump \%loco_data; __DATA__ 123 234 345 456 #{ # "123\n" => 234 # , # "345\n" => 456 # , #}
Also, you should at least use strict;; use warnings; and use diagnostics; will give you even more info.
For opening files it's better to use the 3-element open.
Is the code you posted a cut-n-paste? I don't see where $locodn is coming from, or why you'd need to chop it.
chomp is generally preferable to chop.
To increment variables: $linecnt1++ or $linecnt1 += $x.
|
|---|