in reply to Array in a Hash
First of all, use
use strict; use warnings;
Hashes can't contain arrays, just scalars. References are scalars, though, so the trick is to place references to arrays in the hash.
$fruit{0}{'fruit'} = \@fruit; # my @HoldArray = @{ $fruit{0}{'fruit'} }; # Wasteful copying my $HoldArray = $fruit{0}{'fruit'}; push @$HoldArray, $new_fruit;
etc
|
|---|