Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: perl

by kilinrax (Deacon)
on Nov 10, 2000 at 00:01 UTC ( #40799=note: print w/replies, xml ) Need Help??


in reply to perl

Assuming by 'empty' you mean 'containing only space characters':
open FILE, "file.txt"; my $count; while (<FILE>) { $count++ unless /\S+/; } close FILE; print $count;

Replies are listed 'Best First'.
RE: Re: perl
by the_slycer (Chaplain) on Nov 10, 2000 at 08:36 UTC
    Just as a footnote, if you do not want to count lines that contain a tab or some other such whitespace, you can substitue /\S+/ with /^$/ in either this code or in Fastolife's below
RE: Re: perl
by Fastolfe (Vicar) on Nov 10, 2000 at 00:43 UTC
    This is the best solution I would use, though /\S/ is sufficient.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://40799]
help
Chatterbox?
Discipulus my 'kids' always complain with our car..
[LanX]: true, cars are bad in growing
[marto]: WaitWindow()
[Corion]: Discipulus: You need to respond with 0 to WM_QUERYENDSESSION
[Discipulus]: why win must be SO complicated!?!? maybe i'll ask a SoPW

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2017-01-17 09:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (154 votes). Check out past polls.