Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Answer: How do I strip lines prefixed by a

( #38411=categorized answer: print w/ replies, xml ) Need Help??

Q&A > regular expressions > How do I strip lines prefixed by a "#" contributed by Fastolfe

Generally when I'm reading files that have the potential for comments or blank lines, a simple regular expression or two does the trick:
while (<DATA>) { s/\s#.*//; next unless /\S/; do_something($_); } __DATA__ # This is my file # with a few lines of comments data=here # another comment more=data # more comments and=more # end of file

Replies are listed 'Best First'.
RE: Answer: How do I strip lines prefixed by a
by Fastolfe (Vicar) on Oct 25, 2000 at 20:20 UTC
    That first regexp should have read: s/\s*#.*//;
Log In?

What's my password?
Create A New User
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2016-06-25 09:28 GMT
Find Nodes?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...

    Results (323 votes). Check out past polls.