develooper Front page | perl.perl5.porters | Postings from March 2001

Re: [ID 20010311.001] Regexp replaces using large replacement variables fail some of the time

Thread Previous
From:
Simon Cozens
Date:
March 11, 2001 07:00
Subject:
Re: [ID 20010311.001] Regexp replaces using large replacement variables fail some of the time
Message ID:
20010311150043.A4319@pembro26.pmb.ox.ac.uk
On Sun, Mar 11, 2001 at 01:44:04PM +0000, ian@lynagh.demon.co.uk wrote:
> ($foo = "abcdefghijklmn") =~ s/(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)/${13}/;

Bizarrely, if you change it to /$13/, it works fine. Also, both ${13} and $13
are set correctly *after* this line, it's just during the substitution. The
problem begins at $10. (double digits)

All of this leads me to suspect that the regex engine does a Breathtaking
Optimization and doesn't set match variables until after the match unless it
sees $\d+ or ${\d} in the replacement. It doesn't account for ${\d+}. That is,
of course, pure speculation based on the Way Of Things in terms of the regex
engine.

-- 
This process can check if this value is zero, and if it is, it does
something child-like.
		-- Forbes Burkowski, CS 454, University of Washington

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About