Phoenix.pm: oldest bug in current perl? (Regex replace looses

Scott Walters scott at illogics.org
Mon Dec 22 11:45:57 CST 2003


lightbright# perl
$_="65x";         s/65/$_-65/e; $res1 = $_;
$_="x65x"; s/x//; s/65/$_-65/e; $res2 = $_;
print $res1 eq $res2 ? "ok\n" : "not ok res1[$res1]res2[$res2]\n";
not ok res1[0x]res2[0]

That s/x/// should only remove one 'x'. There is no /g after it. And
the bug (according to the original email) wasn't that it was global,
but the internal machinery loses count of its position under some
circumstances - hard to reproduce circumstances such as this.
I think they had to tweak it slightly to get it to perform in
Perl 4 but it is the same bug.

-scott


On  0, Bill Lindley <wlindley at wlindley.com> wrote:
> 
> Hmm...
> 
> >  $_="65x";         s/65/$_-65/e; $res1 = $_;
> >  
> >
> Looks to me like this should change the "65" to "0" and produce "0x"
> 
> >  $_="x65x"; s/x//; s/65/$_-65/e; $res2 = $_;
> >  
> >
> Looks to me like this should eliminate the 'x's, and produce "0"
> 
> >  print $res1 eq $res2 ? "ok\n" : "not ok res1[$res1]res2[$res2]\n";
> >
> >then I see the same result in perl4 as in bleed:
> >
> >  not ok res1[0x]res2[0]
> >  
> >
> Why's it "not ok"?
> 
> \\/
> 



More information about the Phoenix-pm mailing list