Beefy Boxes and Bandwidth Generously Provided by pair Networks kudra
Keep It Simple, Stupid
 
PerlMonks  

Re: How to create hash out of an array elements?

by ansh batra (Friar)
on Nov 17, 2011 at 09:38 UTC ( #938565=note: print w/ replies, xml ) Need Help??


in reply to How to create hash out of an array elements?

@arr=(1,2,3,4,5,6,7,8,9,10); %hsh= (); $i=0; while($i<10) { $hsh{$arr[$i]}=$arr[$i+1]; $i=$i+2; } while ( my ($key, $value) = each(%hsh) ) { print "$key => $value\n"; }

output
1 => 2 3 => 4 7 => 8 9 => 10 5 => 6


Comment on Re: How to create hash out of an array elements?
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://938565]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2014-04-16 05:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (414 votes), past polls