my %vals_by_type; while () { chomp; my ($type, $val) = split ' '; push @{ $vals_by_type{$type} }, $val; }