use strict; use warnings; while (<>) { my %sequences; for my $char ( split '', (split)[1] ) { $sequences{$char}++; } print "$_ => $sequences{$_}", "\n" for keys %sequences; }
Note how I declared the hash inside the loop. Scoping variables correctly is the easiest way to reset them.
In reply to Re^3: What is wrong in this code???
by Anonymous Monk
in thread What is wrong in this code???
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |