in reply to optimizing code - need help

%hash = map { $_->[0] => $_ } @$array_ref;

Perhaps?

--
<http://www.dave.org.uk>

"Perl makes the fun jobs fun
and the boring jobs bearable" - me

Replies are listed 'Best First'.
Re (tilly) 2: optimizing code - need help
by tilly (Archbishop) on Jan 19, 2001 at 22:36 UTC
    While that looks nice, be very careful to not use a map that returns multiple entries per input with a long list before 5.6.1 is out. Unfortunately it currently scales quadratically:
    %hash = map { $_, $_ } 1..20_000;
    If that doesn't make you a believer, s/20/100/ and try again.

    This applies to all versions of Perl with map until the upcoming 5.6.1.

      Thanks tilly ! and everyone else. You guys rock! =D