Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Count the number of lines in a file

by fletcher_the_dog (Friar)
on May 25, 2004 at 17:56 UTC ( [id://356322]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://356322]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-04-25 17:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found