in reply to problem printing message if search item is not found

That is because this code:
if (!($_ =~ /$search/)) { print "\nsubstring <$search> NOT found\n"; }
is executed outside the loop. So it will print the message always, except for the case when the last line contains the searchword. You have to use a flag.
my $found; my $counter; for (@line) { $counter++; if ($_ =~ /$search/i) { print "\nLine that matched <$search> found on line $counter\n"; print "$_\n"; $found++; } } if ( $found ) { print "$count found words total\n"; } else { print "\nsubstring <$search> NOT found\n"; }


holli, /regexed monk/