Link to home
Start Free TrialLog in
Avatar of SWAYAM4U
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 ?

Avatar of woepwobin
woepwobin

What exactly do you mean by 'take out the value of A' ? What is your expected result?
Avatar of SWAYAM4U

ASKER

After creating the hash
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"?
Avatar of FishMonger
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;

Open in new window

SOLUTION
Avatar of parparov
parparov
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks a lot to everybody