develooper Front page | perl.perl5.porters | Postings from August 2013

second use of lexical isn't COW

Thread Next
From:
Dave Mitchell
Date:
August 19, 2013 11:20
Subject:
second use of lexical isn't COW
Message ID:
20130819111903.GT2177@iabyn.com

FC, I noticed this the other day: this code:

    for (1,2) {
	my $p = 'x';
	use Devel::Peek; Dump $p;
	$p =~ s/x/y/;
    }

outputs

    SV = PV(0x1c95b68) at 0x1cb56e8
      REFCNT = 1
      FLAGS = (PADMY,POK,IsCOW,pPOK)
      PV = 0x1cc5278 "x"\0
      CUR = 1
      LEN = 16
      COW_REFCNT = 1
    SV = PV(0x1c95b68) at 0x1cb56e8
      REFCNT = 1
      FLAGS = (PADMY,POK,pPOK)
      PV = 0x1cfca18 "x"\0
      CUR = 1
      LEN = 16

Notice that the second time round, $p isn't COW after the assignment.
Is this a bug?

I had a quick look at Perl_sv_setsv_flags(), but decided it was easier to
write this email than to try to understand that COW code :-)


-- 
Lear: Dost thou call me fool, boy?
Fool: All thy other titles thou hast given away; that thou wast born with.

Thread Next


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