while (@ref) { my $k = shift(@ref); $out{$k} = [ shift(@ref), shift(@ref) ]; } #### while (@ref) { $out{$_} = [ shift(@ref), shift(@ref) ] for shift(@ref); } #### push @{ $out{shift(@ref)} }, shift(@ref) while (@ref);