in reply to strip perl comment lines

Besides the other comments already in this thread, let me add a few of my own:

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: Re: strip perl comment lines
by epoptai (Curate) on Feb 08, 2001 at 02:27 UTC
    Thanks merlyn. I knew that my strategy would prevent saving a file named 'display', but I wasn't aware of the superior '-' convention. I don't have much experience coding console apps so bear with me. To preserve the context of the replies i won't update the logic of my original code, but did include the warnings you suggested.

    Generally, i'm not suggesting that stripping perl comments is a good idea, because it eliminates very valuable documentation and optional lines of code, and is a highly dubious coding situation (parsing perl). However i find it a useful hack when trying to comprehend heavily commented cargo. In some cases it can reduce the script size by 50% and bring the flow of logic into sharper focus.

    To future readers of this thread, if you need a perl comment stripper i recommend upgrading to danger's more beautiful and efficient version below.

Re: Re: strip perl comment lines
by japhy (Canon) on Feb 07, 2001 at 19:58 UTC
    It's not impossible if you base your comment-remover on the perltidy program. Not sure how you would do that, though.

    japhy -- Perl and Regex Hacker
      No, it's impossible. You can't parse an arbitrary Perl program statically and assign meaning to every token. I've demonstrated that here in my now famous "On Parsing Perl" note. You can get arbitrarily close but there will always be that gap.

      -- Randal L. Schwartz, Perl hacker