SWAYAM4U
asked on
Multidimentional HASH
I am New to perl,Please help me.
I have 2 Arrays
@ARRAYA=(A,B,C,D,E,A);
@ARRAYB=(1,2,3,4,5,6);
I want to Create a hash out of these two array like
%Hash=('A'=>1 ,6 ,' B' =>2,'C'=>3,'D'=>4,'E'=>5) ;
after creating this hash how take out the value of A ?
I have 2 Arrays
@ARRAYA=(A,B,C,D,E,A);
@ARRAYB=(1,2,3,4,5,6);
I want to Create a hash out of these two array like
%Hash=('A'=>1 ,6 ,' B' =>2,'C'=>3,'D'=>4,'E'=>5) ;
after creating this hash how take out the value of A ?
What exactly do you mean by 'take out the value of A' ? What is your expected result?
ASKER
After creating the hash
The KEy is A and it's value is 1 and 6 .
The KEy is A and it's value is 1 and 6 .
And what is your expected result? What do you want the value to be? 1, or 6, or 7, or "1,6"?
use Data::Dumper;
my @arrayA = qw(A B C D E A);
my @arrayB = qw(1 2 3 4 5 6);
my %hash;
@hash{@arrayA} = @arrayB;
print Dumper \%hash;
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a lot to everybody