On Mon, Sep 19, 2011 at 05:49:19PM +0100, Philip Hazel wrote: > I sometimes wonder whether these new backtracking verbs are going to > prove more trouble than they are worth. About the only possibly useful input I think I can have after reading the thread of this bug, and the entire documentation: =item C<(*THEN)> C<(*THEN:NAME)> This is similar to the "cut group" operator C<::> from Perl 6. Like C<(*PRUNE)>, this verb always matches, and when backtracked into on failure, it causes the regex engine to try the next alternation in the innermost enclosing group (capturing or otherwise). Its name comes from the observation that this operation combined with the alternation operator (C<|>) can be used to create what is essentially a pattern-based if/then/else block: ( COND (*THEN) FOO | COND2 (*THEN) BAR | COND3 (*THEN) BAZ ) Note that if this operator is used and NOT inside of an alternation then it acts exactly like the C<(*PRUNE)> operator. / A (*PRUNE) B / is the same as / A (*THEN) B / but / ( A (*THEN) B | C (*THEN) D ) / is not the same as / ( A (*PRUNE) B | C (*PRUNE) D ) / as after matching the A but failing on the B the C<(*THEN)> verb will backtrack and try C; but the C<(*PRUNE)> verb will simply fail. =back is that I'm sadly thinking that you're right about the trouble/worth trade. I don't actually understand any of this. Which isn't a good sign, as based on previous experience I'm going to make the possibly arrogant assumption that *I* am not the one at fault for the lack of understanding. [Nothing uses (*THEN) in the core, other than the 14 lines of tests for it] Nicholas ClarkThread Previous | Thread Next