EchoAngel has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks! I have something like this
my %TEST2 = (); $TEST2{HOHOHO} = "LALALAL"; my %TEST = (); $TEST{"ASDF"} = \%TEST2; my %ASDF = (); $ASDF{"ABC"} = \%TEST; print Dumper (\%ASDF); print "DEBUG AGAIN $ASDF{ABC}{ASDF}\n";
My Data Dump looks like this
$VAR1 = { 'ABC' => { 'ASDF' => { 'HOHOHO' => 'LALALAL' } } };
Is there anyway I can access the data as simple as : $ASDF{ABC}{ASDF} note : I have larger structure of Hashes and they kind of follow the same idea with hash pointers I just want an easy way to access the data in the hash.

Replies are listed 'Best First'.
Re: Help with Viewing Data with In Hash of Hash Pointers
by ikegami (Patriarch) on Nov 05, 2004 at 20:45 UTC
    $ASDF{ABC}{ASDF} works (returns \%TEST2). Printing $ASDF{ABC}{ASDF}{HOHOHO} would print LALALAL.

    Addition: You can do stuff like the following, too:

    foreach (keys %{$ASDF{ABC}{ASDF}}) { print($_, ' => ', $ASDF{ABC}{ASDF}{$_}, $/); }

    I'd make it clearer as follows:

    my $hash_ref = $ASDF{ABC}{ASDF}; foreach (keys %$hash_ref} { print($_, ' => ', $$hash_ref{$_}, $/); }
Re: Help with Viewing Data with In Hash of Hash Pointers
by TedPride (Priest) on Nov 06, 2004 at 13:30 UTC
    Perhaps what you want is a way to reference the deepest level of your nested hashes without typing massive amounts of text?
    $ref = $ASDF{ABC}{ASDF}; for (keys %$ref) { print "$_ => " . $ref->{$_} . "\n"; }