Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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
Domain Nodelet?
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 studying the Monastery: (None)
    As of 2021-10-16 16:12 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      My first memorable Perl project was:







      Results (69 votes). Check out past polls.

      Notices?