in reply to Is this a memory rewriting or else....!

I didn't think Perl's regexp engine could process two regexps at the the same time — but I don't know for sure — yet I see
... while ($content=~ m@...@g ) { ... parseMainNodes($desc, $rs); ... sub parseMainNodes { ... while ($content2=~ m@...@g ) { ...

Replies are listed 'Best First'.
Re^2: Is this a memory rewriting or else....!
by davido (Cardinal) on Jan 24, 2006 at 06:33 UTC

    Actually, in that respect, Perl's regexp engine does handle mutiple "m//g" instances properly. Witness the following code:

    use strict; use warnings; use diagnostics; my( $first, $second ) = ( "a1b2c3d4e5f6", "AaBbCc" ); while( $first =~ m/(\d)/g ) { print "\$first matched on $1\n"; while( $second =~ m/([a-z])/g ) { print "\t\$second matched on $1\n"; } }

    You might be thinking of this quote, from perltodo:

    A re-entrant regexp engine
    This will allow the use of a regex from inside (?{ }), (??{ }) and (?(?{ })|) constructs.


    Dave