in reply to match lines containing state abbreviation
Change your grep to do something useful.
my @keepers = grep /^$match$/, @lines;
...for instance. The problem with your existing code is that $match, used as a simple expression, is simply evaluated in boolean context; if $match contains a value that Perl considers true, the expression will be true. Since "AZ", the string, is always true, every @lines gets grepped into @keepers.
Dave
|
|---|