http://qs1969.pair.com?node_id=356322


in reply to Count the number of lines in a file

Here is one way to do it:
use strict; my $txt = do{ local $/;<>}; # slurp file from the cmd line my $lines = split /\n/,$txt; # use split in scalar context my $chars = length($txt); # find length of whole text print "Chars = $chars Lines = $lines\n";