in reply to Counting keys with defined or undefined elements in a hash

Why not use a tied hash that reserves a key, call it "__UNDEFINED_COUNT__" for instance. Then the tied handlers will increment / decrement the count as appropriate. With this, there will be no need to do any extra counting, grepping, etc. You can just say
my $undefined_count = $my_dna_hash->{'__UNDEFINED_COUNT__'};

It would probably be good to write the tie so that the reserved variable cannot be directly altered, i.e. give a warning or die if if something external tries to modify it.