in reply to [SOLVED] Printing an object when you only have the refaddr string for it
use Test::More tests => 2; use Inline C => <<'__EOC__'; SV* addr_to_ref(IV addr) { return newRV_inc((SV*)addr); } __EOC__ { my @a = qw( a b c ); my $ref = \@a; my $stringified_ref = "$ref"; my $addr = $stringified_ref =~ /0x([0-9a-f]+)/ ? hex($1) : die; my $ref2 = addr_to_ref($addr); is(0+$ref, 0+$ref2); is("@$ref", "@$ref2"); }
That's assuming the SV is still allocated, of course.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Printing an object when you only have the refaddr string for it
by delias_ (Acolyte) on Nov 05, 2015 at 21:23 UTC | |
by delias_ (Acolyte) on Nov 05, 2015 at 21:57 UTC | |
by ikegami (Patriarch) on Nov 06, 2015 at 18:41 UTC |