BrowserUk has asked for the wisdom of the Perl Monks concerning the following question:

Calling test() the first succeeds. When it is called the second time in the loop, it traps?

I know it is non-sensical code, but it is the smallest reduction of the original that still demonstrates the problem. I just cannot see why?

#! perl -slw use strict; our $s = 'testtesttest'; our $t; sub test{ $t = $s; local *_ = \$t; our $i = 0; *_ = \substr($t, $i) while s[([a-z])(?{ $i=pos()+1 })][\U$1]; } test(); print "1 pass:$t"; test() for 1..2; print "After 2 pass:$t"; ## Never executed.

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller

Replies are listed 'Best First'.
Re: AS 5.8 segfaults -- but only on the second attempt?
by hv (Prior) on May 08, 2003 at 01:20 UTC

    There are certainly still some known instabilities introduced by substring references. You might want to browse the bugs database at http://bugs.perl.org for some other examples.

    For what it's worth, the latest bleading-edge perl doesn't have a problem with this testcase, so there's a good chance it'll also be fixed in 5.8.1.

    Hugo

      Thanks Hugo. That the problem is gone in bleed perl is reassuring.

      I just created a user account at bugs.perl.org and received the password. It won't let me log in yet, but I'll give it a few.


      Examine what is said, not who speaks.
      "Efficiency is intelligent laziness." -David Dunham
      "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
Re: AS 5.8 segfaults -- but only on the second attempt?
by The Mad Hatter (Priest) on May 08, 2003 at 00:15 UTC
    Hmmm. Seems like a bug in 5.8 to me, but I'm not really in a position to give an answer. BTW, I get the same results on v5.8.0 built for i686-linux-thread-multi-ld.
Re: AS 5.8 segfaults -- but only on the second attempt?
by cciulla (Friar) on May 08, 2003 at 00:47 UTC

    Me, too.

    Also, it causes Vim 6.1 to die a rather horrible death whilst using "perldo".