more useful options | |
PerlMonks |
Reference Count of a Non-Scalarby bbfu (Curate) |
on Mar 11, 2002 at 03:03 UTC ( [id://150796]=perlquestion: print w/replies, xml ) | Need Help?? |
bbfu has asked for the wisdom of the Perl Monks concerning the following question: Devel::Peek has a function, SvREFCNT, that lets you find out the reference count of a scalar value or variable. Unfortunately, it doesn't seem to have any way of determining the reference count of a non-scalar variable. The only way I have been able to think of to find the ref count for, say, an array variable would be to parse the output of Devel::Peek's Dump function. This seems to me, however, to be a Really Bad Idea. Can anyone point me to a way to get the ref count without resorting to this kind of chicanery? Example Code:
Output (the information I seek is in blue): 2 1 2 SV = RV(0x8103b88) at 0x80fd5c0 REFCNT = 1 FLAGS = (PADBUSY,PADMY,ROK) RV = 0x80fd5a8 SV = PVAV(0x80f77bc) at 0x80fd5a8 REFCNT = 2 FLAGS = (PADBUSY,PADMY) IV = 0 NV = 0 ARRAY = 0x81226e8 FILL = 0 MAX = 3 ARYLEN = 0x0 FLAGS = (REAL) Elt No. 0 SV = IV(0x80ff80c) at 0x80f62ac REFCNT = 1 FLAGS = (IOK,pIOK) IV = 1 bbfu
Back to
Seekers of Perl Wisdom
|
|