in reply to Using MAP to swap around HoA hash keys and array values.

Let's see.

my %new_hash = map { my $v = $hash{$_}; $$v[0], [$_, @$v[1 .. @$v - 1] +] } keys(%hash);

Replies are listed 'Best First'.
Re^2: Using MAP to swap around HoA hash keys and array values.
by diotalevi (Canon) on Jun 12, 2006 at 00:49 UTC
    @$v - 1

    You meant $#$v. @$v - 1 is taking a wrong value and fixing it make it right. $#$v is already right. You should prefer the value that is already right to prevent accidentally getting an off-by-one if you ever forget to include the fixing -1.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊