$/ = undef;
It enables the "slurp mode", i.e. <FILE> reads the whole file into $_. But you then check
which only runs once.if (/$i/g)
You can fix it in several ways:
my $regex = join '|', map quotemeta, @ids; while (<FILE>) { $counts{$1}++ if /($regex)/; }
In reply to Re: Perl beginner's issue with hash
by choroba
in thread Perl beginner's issue with hash
by Maire
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |