in reply to problem printing message if search item is not found
Try something along the lines of
... my $match = 0; for (@line) { ... if ($_ =~ /$search/i) { print ...; $match++; } } if (!match) { print "not found"; }
Read Transient's reply above, he is right. His "found" variable is called $match here. A similar trick is used in this program, where the flag $found_any is used in the same manner, and later it is used to generate the exit code.
|
|---|