in reply to Map: Thou Has't Confounded Me For The Last Time! (Referring To The Array You Are Assigning To In Map)
There was a detailed thread on this before. I don't have time to search for it right now, but it was determined that
%hash = map { getkey($_) => $_ } @array;
is closer to
@anon_temp = (); foreach (@array) { push(@anon_temp, getkey($_), $_); } %hash = @anon_temp;
than to
%hash = (); foreach (@array) { $hash{getkey($_)} = $_; }
and that the %hash = @anon_temp; accounts for the speed difference.
As for your other question, my $something = $value if $something is similar to (or the same as?) (my $something = $value) if $something. The my in executes only if $something was true before this statement. Never use if, unless, etc on a my.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Map: Thou Has't Confounded Me For The Last Time! (Referring To The Array You Are Assigning To In Map)
by halley (Prior) on Feb 14, 2005 at 14:46 UTC | |
by Anonymous Monk on Feb 15, 2005 at 01:29 UTC | |
|
Re^2: Map: Thou Has't Confounded Me For The Last Time! (Referring To The Array You Are Assigning To In Map)
by ikegami (Patriarch) on Feb 14, 2005 at 15:24 UTC |