Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: array to hash key value pairs

by toolic (Chancellor)
on Feb 11, 2013 at 20:51 UTC ( #1018240=note: print w/ replies, xml ) Need Help??


in reply to array to hash key value pairs

List value constructors

use warnings; use strict; my @gene = qw( ATAD3B 83858 ATAD3A 55210 SSU72 29101 SLC35E2 9906 GNB1 2782 TMEM52 339456 GABRD 2563 ); my %gene = @gene;


Comment on Re: array to hash key value pairs
Download Code
Re^2: array to hash key value pairs
by Anonymous Monk on Feb 11, 2013 at 20:59 UTC

    I just figured out how to do it

    %gene = map{S_} @gene;

    Thanks!

Re^2: array to hash key value pairs
by vinoth.ree (Parson) on Feb 12, 2013 at 05:19 UTC
    Hi toolic

    Your code just turns array into hash only. What about "The odd numbers are the keys and the even numbers are the values."

    lomSpace has to clarify this one!

Re^2: array to hash key value pairs
by jms53 (Monk) on Feb 12, 2013 at 11:49 UTC
    what about a foreach?
    my %Gene; for my $index (@gene) { $Gene{$gene[$index]} = $gene[$index+1] if $index%2; }
    J -

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (11)
As of 2014-07-30 13:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (234 votes), past polls