use strict; use warnings; sub main { my @patterns = ("^abd", "ghi"); my $file = 'C:\Perl64\bin\hello.txt'; open(FH, $file) or die("File $file not found"); while(my $String = ) { # if($String = ~ /^abd /) if($String .= join ('/ && /', @patterns); { print "$String \n"; } } close(FH); } main();