in reply to greping thru a hash of arrays

You can grep through it, but you have an error in how you are accessing the array ref. You need to do it like this:
if (grep /$_/, @{$tbl{$i}} ) {
Update: Removed square brackets which I didn't see the first time around.

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
    Thanks, that works. But why?
      grep /$_/, [ @{$tbl{$i}} ]

      means:
      Dereference the array-Ref in $tbl{$i}, make a reference to an anonymous array ( [ ] ) from the resulting list and grep through a list with a single item: the single reference to the anonymous array.

      @tbl{$i} is btw. wrong, see this example :
      $perl perl use strict; use warnings; my %hash; $hash{a} = [ 1,2 ]; print "@hash{a}", $/; Scalar value @hash{a} better written as $hash{a} at - line 7.

      edit: several updates/corrections due to some misleading thoughts while typing too fast

      There were a few errors. As linuxer pointed out, the second argument to grep should not be an array-ref. The second through last arguments are the list of items to grep through.

      Also, instead of @tbl{$i} you want to use @{$tbl{$i}}.