http://www.perlmonks.org?node_id=1018240


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;

Replies are listed 'Best First'.
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 -
Re^2: array to hash key value pairs
by vinoth.ree (Monsignor) 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!

A reply falls below the community's threshold of quality. You may see it by logging in.