use strict; use warnings; my @words = qw(foo bar baz etc.); while (<>){ for my $word (@words){ print "Found $word in $ARGV\n" if (/\Q$word/); } }