http://qs1969.pair.com?node_id=424239


in reply to Bringing Logic Programming to Perl

One of the new features in perl6 that may be useful for this is a switch for rules (patterns) that tells it to find every way this pattern can match, rather than finding only one match for each possible start position. I'm not sure what it's called this week, but it would mean you could say something like:

"abcd" =~ m:every/^(.*)(.*)$/;
.. and get the five matches that represent the five ways of splitting the string into two parts.

I'd also love to see the pattern matching concept extended from simple strings to data structures, but I don't think anyone yet knows of a good paradigm for expressing the patterns. The only halfway useful approach I know of is expat XPath, and the way it expresses its patterns is ugly as hell.

Hugo