http://qs321.pair.com?node_id=621621


in reply to Elegance, dammit!

Purely for completeness.

Option 1:

while (@ref) { my $k = shift(@ref); $out{$k} = [ shift(@ref), shift(@ref) ]; }
or if the temporary bothers you:
while (@ref) { $out{$_} = [ shift(@ref), shift(@ref) ] for shift(@ref); }

Option 2: Change your SQL to something like SELECT key, value1, key, value2, then do:

push @{ $out{shift(@ref)} }, shift(@ref) while (@ref);
Personally, I'd stick with your original.