in reply to push an array into Hash of Array
it makes more sense to havemy @arr=['rose','orange','green']; $hash{"first"}=[@arr];
To add to this array, simplymy @arr = qw(rose orange green); $hash{"first"}=\@arr;
In entirety:push(@{$hash{first}}, qw(red blue));
Update: for your updated question#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my %hash; my @arr = qw(rose orange green); $hash{"first"}=\@arr; push(@{$hash{first}}, qw(red blue)); print Dumper(\%hash); ----- $VAR1 = { 'first' => [ 'rose', 'orange', 'green', 'red', 'blue' ] };
$hash{first} = []; push(@{$hash{first}}, \@arr); ... @newarr = qw(red blue); push(@{$hash{first}}, \@newarr);
|
|---|