my %out; my @in = @{ $in }; my $i = 0; while ( $i < $#in ) { push( @{ $out{ $in[ $i++ ] } }, $in[ $i++ ] ) ; } return \%out;