Devel::Pointer::PP - Fiddle around with pointers, safer than Devel::Pointer


 use Devel::Pointer ':all';
 my $addr = address_of( $val );

 # Dereference by address
 my $val2 = ${deref( $addr )};
 # Dereference a reference
 my $val2 = ${deref( \ $val )};
 # Dereference a stringified reference
 my $val2 = ${deref( "" . \ $val );
 $a = unsmash_sv(0+$scalar_ref);
 @a = unsmash_av(0+$array_ref);
 %a = unsmash_hv(0+$hash_ref);
 &a = unsmash_cv(0+$code_ref); 
 # Yes, you can do that. You get the idea.

 $c = deref(-1);        # *(-1), and the resulting segfault.


The primary purpose of this is to turn a smashed reference address back into a value. Once a reference is treated as a numeric or string value, you can't dereference it normally; although with this module, you can.

Be careful, though, to avoid dereferencing things that don't want to be dereferenced.


All of the above


Joshua ben Jore

Simon Cozens wrote the XS version and then some loony put an object_2svref method into perl 5.8.1's B module and enabled me to rewrite the thing in pure perl.


Devel::Pointer, Devel::Peek, perlref