I'm trying to create a hash in which keys are contained in an array and values in an array of an array:
my @keys = (1,2,3,4,5);
my @value1 = (a,b,c,d,e);
my @value2 = (f,g,h,i,j);
my @value3 = (k,l,m,n,o);
my @values = ([@value1],[@value2],[@value3]);
my %hash;
I want to create a hash with @keys as keys, and @values as values so that key '1' would return the values a,f,k (0th element in each array) and so on.
For a single key this would be achieved as follows:
%hash=('key'=>@values);
But I'm unsure how to modify this for an array of keys.
Any help would be amazing!
Cheers,
N
%hash=('key'=>@values);is wrong. Values must be scalars. You can use%hash = ( key => \@values );or%hash = ( key => [ @values ] );.a,f,knota,g,k