This is exactly the pointer (pun intended :) I was looking for.
The following code accomplishes my task:
#!/usr/bin/perl -T
use strict;
use warnings;
use Devel::Pointer;
eval {
require('some_code.pl');
};
if ($@) {
my $start = index($@, 'HASH(0x') + 7;
my $end = index($@, ')', $start);
my $hex = substr($@, $start, $end-$start);
my $addr = hex($hex);
my $href = unsmash_hv(0+$addr);
print("$$href{'Error data'}\n");
}
# EOF
Since the hash is guaranteed (in my case) to have a non-zero reference count, this code is safe for my purposes. |