while (my $line = ) { ... for my $i (...) { if (grep /$line/, @{$tbl{$i}}) { ... } } }