perl -MRegexp::Assemble -e ' $ra=Regexp::Assemble->new; $ra->add($_) for qw(list of words); local $/=undef; # slurp mode on $re=$ra->re; # create a regex from your list of words while(<>){ print "$1 in $ARGV\n" if $_ =~ m{($re)} }' list of files