my %hash; while ( my ( $key, $val ) = splice( @$in, 0, 2 ) ) { push @{ $hash{$key} }, $val; }