http://www.perlmonks.org?node_id=38411


in reply to How do I strip lines prefixed by a "#"

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*#.*//;