in reply to Re: Efficient Grouping
in thread Efficient Grouping

It would be helpful to handle these rogue entries.
Well, then, to modify tommyw's code:
use strict; my (%hash, @G1_out, @G2_out); my @rogues; $hash{$_}=\@G1_out for qw(H0 H1); # etc $hash{$_}=\@G2_out for qw(PX P2); while (<>) { chomp; push @{$hash{substr($_, 0, 2)} || \@rogues}, $_; }