$words = "(directory|file|age|action)"; while (<>){ if ( $_ !~ /$words/ ){ print "Could not find $_ in \$words\n"; } }