in reply to Re: hashes with arrays
in thread hashes with arrays
Several things there that can be improved on. ;)
The first is that $ref is a hash reference. More likely you simply want a hash:
my %ref;
Perl allows some syntactic sugar that removes all those -> so you can write:
$ref{car}{Toyota}[2]="Corolla";
However if you want to initialize a hash then you can:
my %ref = ( car => { Honda => [qw(Civic Accord)], Toyota => [qw(Camry Tundra Corolla)], } );
taking advantage of qw so that the car names don't require quoting.
|
|---|