Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Memory usage while tallying instances of lines in a .txt file

by SuicideJunkie (Vicar)
on Dec 05, 2016 at 16:47 UTC ( [id://1177245]=note: print w/replies, xml ) Need Help??


in reply to Memory usage while tallying instances of lines in a .txt file

Change the while into while (my $line = <$IFH>) along with the corresponding references to $_ to $line.

Also, there doesn't seem to be any need to test for the existence of the hits keys; simply let them autovivify. You can use ...{w}//0 and ...{c}//0 when printing in case there was only one of the values incremented. That will simplify your main loop to three lines.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1177245]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-25 23:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found