Perl: the Markov chain saw | |
PerlMonks |
Re: Special Variables and Multiple Regexp Matchingby GrandFather (Saint) |
on Nov 18, 2013 at 00:39 UTC ( [id://1063024]=note: print w/replies, xml ) | Need Help?? |
As a general thing providing a focused working stand alone sample script illustrating the problem will get you better answers. Consider:
Prints:
while (lc($line) =~ /token/g) { loops until killed because each time through the loop lc($line) is re-evaluated so the regular expression restarts, so don't do that. So long as $line isn't changed the /g makes the regular expression carry on from where it left off last time through the loop, which is what you want.
True laziness is hard work
In Section
Seekers of Perl Wisdom
|
|