in reply to How to club different lines of program into one

For yet another alternative that allows you to include regular expressions in the patterns to be found:

use strict; use warnings; my $filename = 'file.txt'; open(FH, '<', $filename) or die "$filename: $!"; my $text = do { local $/; <FH> }; close(FH); my @patterns = qw(january february egypt a.*e <sample>(.*?)</sample> e +tc); print map { $text =~ /$_/ ? "$_: found\n" : "$_: not found\n" } @patterns; __END__ january: found february: found egypt: found a.*e: not found <sample>(.*?)</sample>: not found etc: not found

Depending on how you want your patterns interpreted you might want to add the s or m modifiers to the pattern match, to change the behavior of '^', '$' and '.'. See perlre for details.