in reply to Dereferencing a Hash of Arrays
values returns two individual array references, which you can't dereference in one go. You have to iterate over them:
for my $aref (values %alphabet) { say for @$aref; }
Also, you probably meant to take references of the arrays only, not of every element used to initialize the hash. \( ... ) takes references of every element of the (unflattened!) list, so the resulting data structure is
... use Data::Dumper; print Dumper \%alphabet;
$VAR1 = { 'SCALAR(0x783790)' => [ '1', '2', '3', '4' ], 'SCALAR(0x783e50)' => [ '9', '8', '7', '6' ] };
which is probably not what you intended. (The scalar refs are stringified here, because hash keys are always strings in Perl.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Dereferencing a Hash of Arrays
by toro (Beadle) on Jun 14, 2011 at 07:24 UTC | |
by Eliya (Vicar) on Jun 14, 2011 at 07:32 UTC | |
by toro (Beadle) on Jun 14, 2011 at 07:39 UTC |