in reply to array of arrays to hash

You can use a hash slice to get the same result:
#!/usr/bin/perl use warnings; use strict; use Test::More tests => 1; my $ranksUsed = [ [ 1 ], [ 2 ] ]; sub original { my @ranksUsed; for (@$ranksUsed) { push @ranksUsed, $_->[0]; } my %ranksUsed = map {$_ => undef} @ranksUsed; return \%ranksUsed } sub slice { my %ranksUsed; undef @ranksUsed{ map @$_, @$ranksUsed }; return \%ranksUsed } is_deeply(original(), slice(), 'same');

If it's possible for the list to be empty, you need to check for that.

لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ