in reply to Access Complex Hash

You can't because this is a bizarre non-sensical data structure. The part [ key3 => 'Hello' ] is a hash key. It will be coerced to its string representation, e.g. ARRAY(0x759de8). When dumped again, we see something like:
$hash = { key1 => { key2 => { "ARRAY(0x759de8)" => { key4 => 'World' } } } };
I suggest you think again about how you construct this structure, there must be a mistake somewhere.

Replies are listed 'Best First'.
Re^2: Access Complex Hash
by Athanasius (Archbishop) on May 15, 2012 at 13:07 UTC

    Anonymous Monk is correct, you can’t access key3 or 'Hello' (see perlref).

    However, for the record, key4 and 'World' can be accessed as follows:

    #!/usr/bin/perl use strict; use warnings; my $hash = { key1 => { key2 => { [ key3 => 'Hello' ], { key4 => 'World' }, } } }; my ($value2) = values $hash->{key1}{key2}; my ($key4, $value4) = each %$value2; print "\$key4 = '$key4', \$value4 = '$value4'\n";

    Output:

    $key4 = 'key4', $value4 = 'World'

    HTH,

    Athanasius <°(((><contra mundum