in reply to accessing array through array reference in hash

I think you need curly braces around $hash{'aref'} to explicitly cast it as an array. (Not sure if my terminology is correct.)

#!/usr/local/bin/perl -w use strict; my @array = ('one','two','three'); my $aref = \@array; my %hash = (); $hash{'aref'} = $aref; print "Array length is:", scalar(@{$hash{'aref'}}), " \n";
Array length is: 3

No good deed goes unpunished. -- (attributed to) Oscar Wilde

Replies are listed 'Best First'.
Re^2: accessing array through array reference in hash
by phaylon (Curate) on Dec 29, 2005 at 00:27 UTC
    Yep, one could try to memorize that @$ dereferences act on the first part of the expression, namely the '$hash' part. If you want to dereference more than the first part, you enclose it in curlies. perldoc perlref knows more about this.

    Ordinary morality is for ordinary people. -- Aleister Crowley