use Modern::Perl qw /2014/; use Data::Dump qw /dump/; my @searchstrings = qw/trap hair dog I/; my @found; while () { while ( my ( $index, $search ) = each @searchstrings ) { push @{ $found[$index] }, [ $search, $., $_ ] if /$search/; } } say dump(@found); __DATA__ Transformers robots in disguise I whip my hair back and forth I will catch a dog with a trap