in reply to Re^2: Question on SV internals
in thread Question on SV internals
$s = '20 ducks';; Dump $s;; SV = PV(0x18aec0) at 0xa5b48 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x40cad18 "20 ducks"\0 CUR = 8 LEN = 16
Length = 16. Now use it in a numeric constant.
$s += 1;; Argument "20 ducks" isn't numeric in addition (+) at (eval 13) line 1, + <STDIN> line 4. Dump $s;; SV = PVNV(0x40b1eb8) at 0xa5b48 REFCNT = 1 FLAGS = (NOK,pNOK) IV = 20 NV = 21 PV = 0x40cad18 "20 ducks"\0 CUR = 8 LEN = 16
Hm. Length still 16, but we gained an IV = 20 and an NV = 21; so we gained 12 or 16 bytes.
Oh, and the PV no longer reflects the value of the scalar, so when you use it in a string context, a conversion has to happen!
print $s;; 21 Dump $s;; SV = PVNV(0x40b1eb8) at 0xa5b48 REFCNT = 1 FLAGS = (NOK,POK,pNOK,pPOK) IV = 20 NV = 21 PV = 0x40d3068 "21"\0 CUR = 2 LEN = 40
Which modifies the PV and oops, it grew to 40 bytes in the process.
And I don't care how you try to weasel out of it, the evidence is right there for those that care to look. So don't bother.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Question on SV internals
by ikegami (Patriarch) on May 08, 2011 at 16:47 UTC | |
by BrowserUk (Patriarch) on May 08, 2011 at 19:09 UTC | |
by ikegami (Patriarch) on May 08, 2011 at 23:53 UTC |