Does this fix it?
for my $m (m/$regex/g) { # Update: reworked
$matched{$m} = 1;
print "$file $_";
}
Full code:
#!/usr/bin/env perl
use strict;
use warnings;
my @files = <c:/perl64/myfiles/*>;
# record matching regexes
our %matched;
my @nums = ('1203', '1204', '1207');
my $regex = '\b(' . join('|', @nums) . ')\b'; # update: fixed + to .
for my $file ( @files ) {
open my $file_h, '<', $file or die "Can't open $file: $!";
while ( <$file_h> ) {
for my $m (m/$regex/g) { # Update: reworked
$matched{$m} = 1;
print "$file $_";
}
}
}
# Check all nums have been seen
for my $num (@nums) {
if (not exists($matched{$num})) {
print "$num not found\n";
}
}
-QM
--
Quantum Mechanics: The dreams stuff is made of