hurricup has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks!

I'd like to add automatic highlighting of perl syntax errors from perl -cw, but it looks pretty syntax-free. Format is not machine-friendly.

Question: is there any way (some module i guess) that can parse perl's output and give me errors in some strict format?

Googled, but found nothing.

Replies are listed 'Best First'.
Re: Parsing perl syntax errors
by Your Mother (Archbishop) on Feb 15, 2016 at 16:59 UTC

    Probably not (at least not robustly). Perl’s output is not perl. It’s freeform text up to the author who wrote the line(s) of code in question. I doubt there is unity of style over the decades. Might be an interesting project though and with the right tests could result in an error output style guide that could be referenced as a best practice…

      Line number and filename are appended, and that's what a regex in emacs is matching to make the message "clickable".

      If that's not enough, try splain

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!

Re: Parsing perl syntax errors
by GrandFather (Saint) on Feb 15, 2016 at 20:11 UTC

    What structure do you expect to see in the message part of the syntax error? As mentioned already, a standard tail is added:

    <message text> at <script path> line <error line>. Execution of <script path> aborted due to compilation errors.

    For run time errors the message format varies somewhat.

    Premature optimization is the root of all job security