Perl-Sensitive Sunglasses | |
PerlMonks |
comment on |
( [id://3333]=superdoc: 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.If you know where the end of the statment it, then it would have been a trivial question ;) The problem is that you can't guess where the statement ends. Even stripping commments is not a trivial task. Consider the following line:
As you can see this would be tricky. I use '#' as regex delimters quite a lot. There are so many special cases in perl that you can't easily isolate things like "strip comments" or "first statement" into simple parsers. For the origial poster, I would suggest looking at perlTidy for some ideas. Simon Flack ($code or die) $,=reverse'"ro_';s,$,\$,;s,$,lc ref sub{},e;$, =~y'_"' ';eval"die";print $_,lc substr$@,0,3; In reply to Re: Re: Matching first Perl statement.
by $code or die
|
|