use strict; use warnings; my @words = qw{january february egypt}; open my $file, '<', 'file.txt'; my $text = do { local $/; scalar <$file>; }; close $file; for my $word (@words) { print (($text =~ /\Q$word\E/) ? $word : "$word not present"); }