in reply to greping thru a hash of arrays
Update: Removed square brackets which I didn't see the first time around.if (grep /$_/, @{$tbl{$i}} ) {
Another problem, though, is that $_ gets assigned to in the grep operation, and that the match operator implicitly operates on $_. Thus, grep /$_/, ... is equivalent to grep { $_ =~ /$_/ } (...) which is probably not what you want. Instead, try this:
while (my $line = <IN>) { ... for my $i (...) { if (grep /$line/, @{$tbl{$i}}) { ... } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: greping thru a hash of arrays
by pglenski (Beadle) on May 20, 2008 at 21:10 UTC | |
by linuxer (Curate) on May 20, 2008 at 21:15 UTC | |
by pc88mxer (Vicar) on May 20, 2008 at 21:19 UTC |