use warnings; use strict; use Data::Dumper; # Populate Array my @fruits = qw( Apple pear Bananna Peach ); # Populate Hash, using a reference to the array my %fruit = ( total => 248, fruit => \@fruits ); # Next Fruit to be added my $new_fruit = "Grapes"; push @{ $fruit{fruit} }, $new_fruit; #print Dumper(\%fruit); # Print out Total fruit and list fruit print "There are $fruit{total} pieces of fruit. "; print "The following is a list of the fruit \n"; for ( @{ $fruit{fruit} } ) { print "$_ \n"; } __END__ Actual output ============= There are 248 pieces of fruit. The following is a list of the fruit Apple pear Bananna Peach Grapes
In reply to Re: Array in a Hash
by toolic
in thread Array in a Hash
by g_speran
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |