In perl, explicit code like this is not necessary as it would be in something more verbose like java or python. Perl has a concept of autovivification, where new values burst into being when needed. Also, ++ on a false value will return 1.
In the case where $hit[2] is not a key in %genus, requesting the key will create a corresponding value of undef. Incrementing this value will return 1.
so this snippet:
#old snippet
if (exists ( $genus {$hit[2]})) {
$genus{$hit[2]}++;
} else{
$genus{$hit[2]} = 1;
}
can be reduced to this snippet:
#new snippet
$genus{ $hit[2] }++
Example:
%genus = { } ; #genus is empty
$genus{ foo }; #requests foo entry, and throws away.
#genus is now { foo => undef }
$genus{ foo } ++; # genus is now { foo => 1 }
http://en.wikipedia.org/wiki/Autovivification