What Anonymous Monk said:
while (my ($match) = m/$regex/g) {
$matched{$match} = 1;
print "$file $_";
}
gives you an infinite loop.
c:\@Work\Perl\monks>perl -wMstrict -le
"my $regex = qr{ \b f[eio]e \b }xms;
;;
$_ = 'xx fee fie foe yy';
while (m/($regex)/g) {
my $match = $1;
print qq{captured '$match'};
}
"
captured 'fee'
captured 'fie'
captured 'foe'
works better (at least it stops). If you want to get a bit fancy,
while (m/($regex)/g and my $match = $1) {
print qq{captured '$match'};
}
also works. But the whole "extract multiple matches per line" thing may not even be a real issue! The OPer says nothing about it, and I only raised it as a cautionary point of interest.
Give a man a fish: <%-{-{-{-<