Just another Perl shrine | |
PerlMonks |
Re: Memory usage while tallying instances of lines in a .txt fileby choroba (Cardinal) |
on Dec 05, 2016 at 16:48 UTC ( [id://1177246]=note: print w/replies, xml ) | Need Help?? |
Help us to help you! Next time, please post code and data we can easily test. See my code below for an example - it should work right ahead. To print 0 instead of undef, you can use the defined-or // operator. It needs Perl 5.10, otherwise you have to be more verbose (defined $_ ? $_ : 0).
Have you noticed I used $_ only in map and first? Both chomp and split work with it by default. If you feel the need to explicitly type the argument, name the variable.
In Section
Seekers of Perl Wisdom
|
|