You've already gotten the fix, but the important thing to note here is that you don't have to "start" a hash value with anything. You can just increment it, and it will be created and set to 1 if it didn't already exist. That saves you from having to do code like this, which might be necessary in lower-level languages:
if( $gene_count{$key} ){ # it already exists $gene_count{$key}++; # so increment it } else { # it doesn't exist $gene_count{$key} = 1; # so create and set it }
Aaron B.
Available for small or large Perl jobs and *nix system administration; see my home node.
In reply to Re: Looping through a file, reading each line, and adding keys/editing values of a hash
by aaron_baugher
in thread Looping through a file, reading each line, and adding keys/editing values of a hash
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |