foreach (@words) {
$line =~ s/([%\d])$_([%\d])//g;
print "$line\n";
}
So the regex is saying this:
Look for either a percent sign or a digit (which will be captured in $1) followed by the string in $_ followed by another percent sign or a digit (which will be captured in $2)
And if all that is found then it's replaced by an empty string.
So as your data doesn't appear to contain any digits or percent signs, then none of that is ever going to match. I think that what you actually wanted was far simpler.
foreach (@words) {
$line =~ s/\b$_\b//g;
print "$line\n";
}
And I think you may want to move the print statement out of the loop - tho' it might be there for debugging purposes.
See perlretut for a good introduction to regexes.
--
< http://dave.org.uk>
"The first rule of Perl club is you do not talk about
Perl club." -- Chip Salzenberg
|