in reply to Re^8: Print word from text file that is not an exact match
in thread Print word from text file that is not an exact match
It doesn't work when searching for a list of computers. If some of the computers are found the one(s) not found "No matches found" is not returned. Is there a way to print "$name - no matches found\n"; In the following block of code? Maybe something like this?# result if ($count){ print "$count matches\n"; } else { print "No matches found\n";
-Tony# search text file open IN, '<',$file or die "Could not open $file : $!"; while (my $line = <IN>){ # repeat line search for each computer foreach my $search (@computers) { if ( my ($name) = $line =~ /($search[\.\w]*)/ ){ print "Name ; $name\n"; ++$count; } else if ( my ($name) = $line =~ /($search[-eq " "]*)/ ){ print "$name -- No matches found\n"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^10: Print word from text file that is not an exact match
by poj (Abbot) on Jun 11, 2018 at 07:53 UTC | |
by TonyNY (Beadle) on Jun 12, 2018 at 01:49 UTC |