Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Count number of lines in a text file

by Anonymous Monk
on Jan 23, 2013 at 08:53 UTC ( #1014861=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    while (sysread FILE, $buffer, 4096) {
            $lines += ($buffer =~ tr/\n//);
        }
    
  2. or download this
    while (<FILE>) {
      $lines++
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1014861]
help
Chatterbox?
[Eily]: I tried print eval '2+1/3*(2+2/5))' or print $@
[Eily]: and therefore concluded that the eval did succeed because there was no printed error :P
[Eily]: stupid operator precedence :D

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (11)
As of 2017-10-24 10:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (287 votes). Check out past polls.

    Notices?