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

Re^2: How can I read and print lines that has only one word from a file

by tadman (Prior)
on Jul 15, 2002 at 04:17 UTC ( [id://181692]=note: print w/replies, xml ) Need Help??


in reply to Re: How can I read and print lines that has only one word from a file
in thread How can I read and print lines that has only one word from a file

Or alternatively, being a little more accomodating:
while (<>) { print if (/^\s*\S+\s*$/); }
You can call this with either one file, or as many as you like. The double-angle-brackets just read in anything from @ARGV. Further, it looks for a single group of "non-space" characters. This includes things with punctuation and such.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (7)
As of 2024-04-19 16:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found