in reply to Efficient Grouping

You've got six if's in the body of the loop, which will probably be more overhead than the setup, if you've got any substantial amount of data. Certainly, you're not going to get much benefit out of the various ways of initialising a 1200 element structure (although some ways may be more readable than others).

my (%hash, @G1_out, @G2_out, ...); $hash{$_}=\@G1_out for (qw (H0 ...)); $hash{$_}=\@G2_out for (qw (PX ...)); while (my $input = <STDIN>) { chomp $input; my $prefix=substr($input, 0, 2); push @{$hash{$prefix}}, $input; }

--
Tommy
Too stupid to live.
Too stubborn to die.