Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: File length ??

by charnos (Friar)
on Sep 12, 2002 at 20:00 UTC ( #197329=note: print w/replies, xml ) Need Help??


in reply to File length ??

Are you trying to determine the number of lines in the data file after taking out blank lines? Also, what's blank? Does blank include spaces? My suggestion would be as such:
@data = grep { $_ !~ /^\s*$/ } @a; my $length = scalar @data;
That is assuming that blank lines may or may not include spaces. If you know that they will not, you could save yourself a good deal of time (especially for large files) by simply testing $_ ne "" in the grep.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2022-08-11 17:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?