in reply to array of arrays to hash

This works too:
my $ranksUsed = [ [ 1 ], [ 2 ] ]; # No intermediate array or loop... my %ranksUsed = map {$_->[0] => undef} @$ranksUsed;
Produces:
$VAR1 = { '1' => undef, '2' => undef };

        "You're only given one little spark of madness. You mustn't lose it."         - Robin Williams

Replies are listed 'Best First'.
Re^2: array of arrays to hash
by AnomalousMonk (Archbishop) on Oct 06, 2014 at 18:02 UTC

    This has the advantage, IMHO, that it produces the same result as the OPed code in the case that the array or any sub-array(s) are empty.