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";