perl-asp mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Henrik Tougaard <>
Subject RE: Parser optimisation
Date Tue, 29 May 2001 07:45:52 GMT
> > -    while($$data =~ s/^(.*?)\<\%(.*?)\%\>//so) {
> > +    while($$data =~ /(.*?)\<\%(.*?)\%\>/gso) {
> I'm not convinced that this does the right thing.  If you don't
> consume the head of the data, then 2nd,3rd,etc ASP block should
> not be picked up correctly.  Does a regexp parser know that it
> should pick up where it left off from the last match in the string?
> I have never seen that behavior documented if it is correct.

It's documented in L<perlop>:

 The /g modifier specifies global pattern matching--that is,
 matching as many times as possible within the string. How it
 behaves depends on the context. In list context, it returns
 a list of the substrings matched by any capturing parentheses
 in the regular expression. If there are no parentheses, it
 returns a list of all the matched strings, as if there were
 parentheses around the whole pattern.

 In scalar context, each execution of m//g finds the next
 match, returning true if it matches, and false if there
 is no further match. The position after the last match
 can be read or set using the pos() function; see perlfunc/pos.

I think that it will work.

Henrik Tougaard, FOA, Copenhagen, Denmark.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message