There's more than one way to do things | |
PerlMonks |
Re: Split a sentence into wordsby ikegami (Patriarch) |
on May 30, 2009 at 07:05 UTC ( [id://767014]=note: print w/replies, xml ) | Need Help?? |
Don't use my variables declared outside the regex pattern from within (?{}). The problem you are having is that one of the patterns matches, then gets added to @list1, then gets unmatched by backtracking. But you never remove it from @list1 on backtracking. A simple example of this:
The solution is to use $^R.
Without the sort, you'd get abd-a-a-bc. If you want all possible solutions:
In Section
Seekers of Perl Wisdom
|
|