in reply to Re^5: Bolt on where a match is not found to a print script
in thread Bolt on where a match is not found to a print script
What Anonymous Monk said:
gives you an infinite loop.while (my ($match) = m/$regex/g) { $matched{$match} = 1; print "$file $_"; }
works better (at least it stops). If you want to get a bit fancy,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'
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.while (m/($regex)/g and my $match = $1) { print qq{captured '$match'}; }
Give a man a fish: <%-{-{-{-<
|
|---|