Don't ask to ask, just ask | |
PerlMonks |
Re: Matching first Perl statement.by talexb (Chancellor) |
on Jan 15, 2002 at 01:42 UTC ( [id://138719]=note: print w/replies, xml ) | Need Help?? |
I'd suggest working from the back of the statement, stripping off the trailing comment (if it exists) until you find a semi-colon. Munch the leading white space, then you're done -- for the trivial cases.
For a full-featured, robust solution, you will most likely need to use Parse::RecDescent or something else. This is, of course, a dangerous question to answer because a problem is posed without much definition of how rigorous the answer should be. Caveat emptor. --t. alex "Of course, you realize that this means war." -- Bugs Bunny.
In Section
Seekers of Perl Wisdom
|
|