Question : Perl map - need to map a array into a hash as arrayelement->array_index

Posted by TGV on Stack Overflow See other posts from Stack Overflow or by TGV
Published on 2010-06-02T13:04:07Z Indexed on 2010/06/11 17:12 UTC
Read the original article Hit count: 175

Filed under:
|
|
|

Hi folks.

I have a array like this:

my @arr = ("Field3","Field1","Field2","Field5","Field4");

Now i use map like below , where /DOSOMETHING/ is the answer am seeking.

my %hash = map {$_ => **/DOSOMETHING/** } @arr

Now I require the hash to look like below:

Field3 => 0
Field1 => 1
Field2 => 2
Field5 => 3
Field4 => 4

Any help?

© Stack Overflow or respective owner

Related posts about perl

Related posts about arrays