in reply to Efficient Grouping

You could use
@G1_Hash{ qw/HO KO.../ } = ();
To make the assignment one step, but this won't be a significant change when comparing to a more efficient loop. You could make the loop more efficient by making your test cases ordered by probability, and then skip to the next line without testing it again with
push (@G1_out, $input), next if exists $G1_Hash{$prefix}
The exists function is just to fix my prior laziness - assiging an empty list to the hash slice - which will result in the values being undefined. I don't know, but perhaps not testing for truth on the value may save a bit more...

Due to the fact that the loop will probably be performed many times over, a little change can be multiplied by the number of times a step is saved.

-nuffin
zz zZ Z Z #!perl