for my $f (@f) { my ($t) = grep {$f=~/$_/} @t; next unless $t; push( @{ $y{ $t } }, $f ); }