Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
The script works very well to match and print each time the number exists on a line in one or more of the files. My question is that I would like to be able to identify when there is no match at all for that number in any of the files (i.e. id didn't find the match in any of the files and im letting you know). To clarify, I still need to match and print every time the number is matched in every file, not just if it was matched once. also the line output where it matches is critical to be printed. ultimately this is just to show if the number was not matched anywhere in any of the files.
#!/perl/bin/perl use strict; use warnings; my @files = <c:/perl64/myfiles/*>; foreach my $file ( @files ) { open my $file_h, '<', $file or die "Can't open $file: $!"; while ( <$file_h> ) { print "$file $_" if /\b1203\b/; print "$file $_" if /\b1204\b/; print "$file $_" if /\b1207\b/; } }
|
|---|