Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
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 (Chaplain) 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: (8)
As of 2014-12-27 08:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (176 votes), past polls