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
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
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
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