Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: Update references

by Eliya (Vicar)
on May 13, 2012 at 21:00 UTC ( #970333=note: print w/ replies, xml ) Need Help??


in reply to Re: Update references
in thread Update references

The reference refers to the scalar retrieved via $a[0], not the array index [0].  The reference knows nothing about the array that scalar came from.  And the scalar will exist as long as its refcount is > 0.

$ perl -MDevel::Peek -E'@a=qw(a b c); $r=\$a[0]; Dump $r; @a=(); Dump +$r' SV = IV(0xa95bc0) at 0xa95bd0 REFCNT = 1 FLAGS = (ROK) RV = 0xa77998 SV = PV(0xa75c20) at 0xa77998 REFCNT = 2 <--- FLAGS = (POK,pPOK) PV = 0xa8ee40 "a"\0 CUR = 1 LEN = 16 SV = IV(0xa95bc0) at 0xa95bd0 REFCNT = 1 FLAGS = (ROK) RV = 0xa77998 SV = PV(0xa75c20) at 0xa77998 REFCNT = 1 <--- FLAGS = (POK,pPOK) PV = 0xa8ee40 "a"\0 CUR = 1 LEN = 16

(note the refcounts)


Comment on Re^2: Update references
Select or Download Code
Re^3: Update references
by stevieb (Deacon) on May 13, 2012 at 21:09 UTC

    That's what I was after, and it makes complete sense. Thanks!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://970333]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2015-07-03 00:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (47 votes), past polls