in reply to Bolt on where a match is not found to a print script
Keep a tally:
#!/perl/bin/perl use strict; use warnings; my @files = <c:/perl64/myfiles/*>; my $total = 0; foreach my $file ( @files ) { open my $file_h, '<', $file or die "Can't open $file: $!"; while ( <$file_h> ) { if (/\b120[347]\b/) { print "$file $_"; $total++; } } } print "No files matched.\n" unless $total;
(Edited for typos)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Bolt on where a match is not found to a print script
by QM (Parson) on Dec 05, 2017 at 11:46 UTC | |
by hippo (Archbishop) on Dec 05, 2017 at 12:30 UTC | |
by Anonymous Monk on Dec 05, 2017 at 13:05 UTC | |
by hippo (Archbishop) on Dec 05, 2017 at 13:20 UTC |