Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: parsing comments in newline-delimited files as lists

by frag (Hermit)
on Dec 27, 2001 at 03:45 UTC ( [id://134512]=note: print w/replies, xml ) Need Help??


in reply to parsing comments in newline-delimited files as lists

Your regular expression isn't correct, in a few ways:
  1. my ($enabled) = /([^\s#]+)#/; doesn't work, because it specifies that there can't be any spaces between the valid text and the #. Add \s*.
  2. To catch lines that aren't commented at all, change # to #?
  3. Now you'll wind up matching "acommentedoutline" in "#acommentedoutline". Block that by adding ^\s* to the start of the regexp; now the match has to be between the start of the line and the first #, if there is one.

-- Frag.
--
"Just remember what ol' Jack Burton does when the earth quakes, the poison arrows fall from the sky, and the pillars of Heaven shake. Yeah, Jack Burton just looks that big old storm right in the eye and says, "Give me your best shot. I can take it."

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-20 02:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found