in reply to Getting the PV pointer from a SV
This version also support 64-bit versions of Perl.
$ perl -E' use Config qw( %Config ); my $ptr_size = $Config{ptrsize}; my $ptr_format = $ptr_size == 4 ? "L" : $ptr_size == 8 ? "Q" : die("Unrecognized pointer size"); my $s = "abc"; my $ptr = unpack($ptr_format, pack("p", $s)); say sprintf "0x%x", $ptr; use Devel::Peek; Dump($s); ' 0x1766c40 SV = PV(0x174dcf0) at 0x176d958 REFCNT = 1 FLAGS = (PADMY,POK,pPOK) PV = 0x1766c40 "abc"\0 CUR = 3 LEN = 16
You should call utf8::upgrade or utf8::downgrade first to control the storage format of the string.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Getting the PV pointer from a SV
by rodd (Scribe) on Mar 09, 2016 at 15:02 UTC | |
by ikegami (Patriarch) on Mar 09, 2016 at 17:28 UTC |