use strict; my $filename = '/home/cgmd/bin/learning_perl/sample_text'; open FILE, $filename or die "Can't open '$filename': $!"; chomp(my @strings = ); print "Please enter a pattern: "; while ((my $pattern = )!~/^\s$/) { chomp $pattern; my @matches = eval { grep /$pattern/, @strings; }; if ($@) { print "Error: $@"; } else { my $count = @matches; print "There were $count matching strings:\n", map "$_\n", @matches; print "Please enter a pattern: "; } print "\n"; }