in reply to Looping through a file, reading each line, and adding keys/editing values of a hash
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Looping through a file, reading each line, and adding keys/editing values of a hash
by Anonymous Monk on Nov 10, 2015 at 06:13 UTC |