in reply to idiom for building hash of arrays?

If you don't need @vals after you've built the hash, this will build your hash without using any modules:
use Data::Dump 'pp'; # a nicer Data::Dumper my @keys = qw {red blue red}; my @vals = (1, 2, 3); my %hash; push @{$hash{$_}}, shift @vals for @keys; pp \%hash; __END__ { blue => [2], red => [1, 3] }

If you do need @vals, you could replace the above loop with:

push @{$hash{$keys[$_]}}, $vals[$_] for 0..$#keys;

Update: Re-added the call to pp


Unless I state otherwise, all my code runs with strict and warnings