rodd has asked for the wisdom of the Perl Monks concerning the following question:
While debugging some code that's printing "HASH(0x9999999)" to stdout, I'd like to be able to parse that out and convert it to a real Perl hash to be able to identify the hash's origin from looking at its contents.
I found I can peek into its data structure using the following:
my ( $addr ) = 'HASH(0x9999999)' =~ /HASH\(0x(.*)\)/; $addr = hex $addr; my $hash_dump = pack 'L', $addr;
But unfortunately $hash_dump is not a HASH but just memory garbage.
How can I convert the address into a valid Perl HASH (or HASH ref)?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to turn "HASH(0x1234567)" into a real HASH
by ikegami (Patriarch) on Oct 13, 2017 at 17:23 UTC | |
|
Re: How to turn "HASH(0x1234567)" into a real HASH
by LanX (Saint) on Oct 13, 2017 at 16:49 UTC | |
by rodd (Scribe) on Oct 13, 2017 at 17:00 UTC | |
by LanX (Saint) on Oct 13, 2017 at 17:02 UTC | |
|
Re: How to turn "HASH(0x1234567)" into a real HASH
by haukex (Archbishop) on Oct 14, 2017 at 18:04 UTC |