in reply to Dereferencing a Hash of Arrays

The reference operator here is a mistake, but it saves you a worse error:

my %alphabet = \(

You need to take references to both arrays in the list used to initialize the hash without taking references to the strings intended as keys.

Replies are listed 'Best First'.
Re^2: Dereferencing a Hash of Arrays
by toro (Beadle) on Jun 14, 2011 at 07:30 UTC

    input:

    my @atags = qw( 1 2 3 4 ); my @btags = qw( 9 8 7 6 ); my %alphabet = ( 'a' => \@atags, 'b' => \@btags, ); say for @{values %alphabet};

    output:

    Can't use string ("2") as an ARRAY ref while "strict refs" in use at ./concat.pl line 9 (#1) (F) Only hard references are allowed by "strict refs". Symbolic references are disallowed. See perlref. Uncaught exception from user code: Can't use string ("2") as an ARRAY ref while "strict refs" in use +at ./concat.pl line 9. at ./concat.pl line 9

      From perldoc values:

      (In a scalar context, returns the number of values.)

      You'll see the error to which I alluded if you print the keys of the hash.