develooper Front page | perl.perl5.porters | Postings from September 2011

Re: [perl #92898] (*THEN) broken inside condition subpattern

Thread Previous | Thread Next
Philip Hazel
September 28, 2011 03:11
Re: [perl #92898] (*THEN) broken inside condition subpattern
Message ID:
On Mon, 26 Sep 2011, Father Chrysostomos via RT wrote:

> *at the current starting position*
> (*THEN) acts like (*COMMIT) in the example given above.


Since we are quoting "man perlre", here's another bit of confusion:

   "(?PARNO)" "(?-PARNO)" "(?+PARNO)" "(?R)" "(?0)"
              Similar to "(??{ code })" except it does not involve
              compiling any code, instead it treats the contents of a
              capture buffer as an independent pattern that must match at
              the current position. 

Consider this pattern (ignore white space):

  ^.*? (?1) c (?(DEFINE) (a(*THEN)b) )
When I read "an independent pattern", it suggests to me that the effect 
of (*THEN) is confined to that independent pattern. However, experiment 
with Perl shows that I am wrong here as well. The pattern as it stands
does not match "aabc", but if |(*F) is added after b, it does. 

As it happens, PCRE processes recursions/subroutines differently to
Perl, or perhaps I should say that the other way round, since PCRE had
them first. :-) So another difference probably doesn't matter much.

However, I'm still thinking about this whole issue with regard to PCRE
implementation. It tries to resolve where (*THEN) should back up to at
compile time, but looking at the example above, it seems to me that it
can only be done dynamically, at run time.


Philip Hazel

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About