Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: File length ??

by charnos (Friar)
on Sep 12, 2002 at 20:00 UTC ( [id://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?

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-05-22 20:30 GMT
Find Nodes?
    Voting Booth?

    No recent polls found