in reply to Re: Stripping Comments from Source
in thread Stripping Comments from Source

If you're skiled with Perl, any reason why you can't write a script (a Perl script, of course) to use a regex to strip out comments from your other Perl script?

It's not trivial to parse Perl even for a skilled programmer!

e.g. regarding comments, you have to handle # delimiters and # in strings

$a="/#/"; $a=~ s#/##g;

(update) and these are only simple cases, even perltidy and PPI can fail in pathological cases. For a detailed discussion search for perl static parsing!

Cheers Rolf

Replies are listed 'Best First'.
Re^3: Stripping Comments from Source
by AnomalousMonk (Archbishop) on May 12, 2010 at 15:37 UTC

    Not to mention my own favorite syntax-highlighting-editor-confusers  $#array (highest index of @array) and the  $# special variable!

      seriously ... which editors?

      I somehow remember emacs having problems with s### 10 years ago with a then antique perl-mode...

      Cheers Rolf

        seriously ... which editors?
        Just look at syntax highlighting. They all have code snippets where they highlight it the wrong way.

        Nothing so sophisticated as emacs. Basically, editors, not terribly modern, designed to be most at ease in C/C++/Java and the like; can't remember specifically just which one(s) just now.

Re^3: Stripping Comments from Source
by mzedeler (Pilgrim) on May 13, 2010 at 11:56 UTC
    # FIXME Why doesn't this change behaviour when I compile it? print <<'END_TEXT'; Just stripping the remaining chars starting with # will not work END_TEXT
Re^3: Stripping Comments from Source
by ambrus (Abbot) on May 14, 2010 at 10:40 UTC