Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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

by SuicideJunkie (Vicar)
on Dec 05, 2016 at 16:47 UTC ( #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
Node Status?
node history
Node Type: note [id://1177245]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2021-02-25 00:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?