use strict; my ($Filename, @array, $searchstring, @stringsfound, @file); print "Please enter the name of the file:"; $Filename = ; chomp($Filename); $Filename = "C:\\Perl\\".$Filename; open IN, $Filename or die "Could not open file $!"; @file = ; close(IN); @array = ('file', 'this', 'dog', 'forward'); foreach (@file){ foreach $searchstring (@array) { if (m/(.*?)$searchstring/i) { push @stringsfound, $searchstring; } } } print @stringsfound;