develooper Front page | perl.perl5.porters | Postings from January 2005

Re: /(?{...})/ bug?

Thread Previous | Thread Next
Dave Mitchell
January 28, 2005 14:17
Re: /(?{...})/ bug?
Message ID:
On Fri, Jan 28, 2005 at 09:40:30PM +0100, Torsten Foertsch wrote:
> I expect the program below to print "klaus" three times. But it prints only 
> one "klaus". If I change the "my $pos=pos" to "$pos=pos". It works as 
> expected. Is that a bug? Or is it documented somewhere?

it can be reduced to the following code:

    my $s="a a a a a";
    $s=~ m{ (?{ my $x = 1; }) }x;
    use Devel::Peek;

which gives (on bleedperl)

    SV = PVMG(0xa107308) at 0xa0d9618
      REFCNT = 1
      IV = 0
      NV = 0
      PV = 0xa0d0848 "a a a a a"\0
      CUR = 9
      LEN = 10

ie after the match, $s has been processed as going out of scope; most
likely the undeffing of $x is somehow undeffing $s instead.

I'd investigate further, but I've just noticed that watchpoints seem to be
broken on gdb with FC3 and current updates.

"Do not dabble in paradox, Edward, it puts you in danger of fortuitous
wit." -- Lady Croom - Arcadia

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About