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.
In reply to Re: Map: Thou Has't Confounded Me For The Last Time! (Referring To The Array You Are Assigning To In Map)
by ikegami
in thread Map: Thou Has't Confounded Me For The Last Time! (Referring To The Array You Are Assigning To In Map)
by Revelation
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |