in reply to Re: Access Complex Hash
in thread Access Complex Hash
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
|
|---|