Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: What is wrong in this code???

by Anonymous Monk
on Dec 07, 2012 at 21:33 UTC ( #1007828=note: print w/replies, xml ) Need Help??


in reply to Re^2: What is wrong in this code???
in thread What is wrong in this code???

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1007828]
help
Chatterbox?
[Corion]: Oooh - I had another devious idea - "Host C" - a C language where every struct is 4K in size. This makes memory and disk access incredibly fast ;)

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2017-04-25 08:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (449 votes). Check out past polls.