in reply to How to turn "HASH(0x1234567)" into a real HASH
There's no telling if the hash still exists! If it doesn't, this could kill or corrupt your process. In other words, using this (or any other solution) is wrong!
use Carp qw( croak ); use Inline C => <<'__EOS__'; SV* _newRV(UV addr) { return newRV((SV*)addr); } __EOS__ sub destringify_ref { $_[0] =~ /\(([^()]*)\)/ or croak("Invalid input"); return _newRV(hex($1)); } my %hash = ( a => 2, b => 3 ); my $ref = \%hash; $ref = "$ref"; $ref = destringify_ref($ref);
|
|---|