Re: transform array into hash

2005-05-05 Thread Ing. Branislav Gerzo
John Doe [JD], on Friday, May 6, 2005 at 10:10 (+0200) thinks about: JD> Another solution (beside Xavier's one) with no need to know the number of JD> elements: JD> my $i=0; # or even: my $i; my %hash=map {$_ => ++$i} qw /one two three four/; yes, I thought about this one too, but Xaviers one is

Re: transform array into hash

2005-05-05 Thread John Doe
Am Donnerstag, 5. Mai 2005 23.07 schrieb Ing. Branislav Gerzo: > Hi all, > > just easy question, here is too much hours and my brain doesn't work > any more. How to transform array into hash ? > > my @array = 1..4; > > I want to have: > %hash = ( one => 1, two => 2, three => 3, four => 4 ); > > tri

Re: transform array into hash

2005-05-05 Thread Xavier Noria
On May 5, 2005, at 23:07, Ing. Branislav Gerzo wrote: tried something like this, but it doesnt work: my $hash{qw/one two three four/} = (1..4); You were quite close: my %hash; @hash{qw/one two three four/} = 1..4; The problem was that "my" accepts variables (modulus details), not expressi

RE: transform array into hash

2005-05-05 Thread Moon, John
Subject: transform array into hash Hi all, just easy question, here is too much hours and my brain doesn't work any more. How to transform array into hash ? my @array = 1..4; I want to have: %hash = ( one => 1, two => 2, three => 3, four => 4 ); tried something like this, but it doesnt work: m