Re: Tool that detects perl syntax errors
by davido (Cardinal) on Oct 31, 2005 at 17:12 UTC
|
Some errors such as a missing closing quote, or a missing semicolon can mask subsequent errors until the primary error is fixed. That makes it difficult for such a tool to exist. I personally just use perl -c scriptname along with a syntax-highlighting editor.
| [reply] [d/l] |
|
|
| [reply] |
|
|
Yeah! Give me a tool that corrects syntax errors and I give you a Perl that really DWIMs :)
| [reply] [d/l] |
Re: Tool that detects perl syntax errors
by Limbic~Region (Chancellor) on Oct 31, 2005 at 17:14 UTC
|
mosh,
The answer is most likely no. As you may have noticed, perl -wc script will only give you the warnings and errors until it blows up. Fixing those may lead to new warnings/errors. Perl goes to great lengths to be forgiving but at some point the parser has to give up. Even the best syntax highlighters fail some pretty common bugs - parsing Perl isn't easy.
There are two projects I am aware of that might be of interest. The first is the work Larry is doing on parsing Perl for Perl6. This work isn't currently public AFAIK. The other is PPI.
| [reply] |
Re: Tool that detects perl syntax errors
by zentara (Cardinal) on Oct 31, 2005 at 18:07 UTC
|
Perltidy will list all the syntax errors it can find. It's not perfect though.
I'm not really a human, but I play one on earth.
flash japh
| [reply] |
Re: Tool that detects perl syntax errors
by davidrw (Prior) on Oct 31, 2005 at 17:14 UTC
|
Do you have specific examples of errors you would like to catch? the default, of course, (see perlrun) is:
perl -c my_prog.pl
Also be use that you have use strict; and use warnings; in your code (perldoc both of those for more details). | [reply] [d/l] [select] |
Re: Tool that detects perl syntax errors
by kirbyk (Friar) on Oct 31, 2005 at 17:23 UTC
|
Also, ActiveState's IDE Komodo has some syntax checking abilities built in. This might be what you're looking for.
Other than that, perl -c and frequent incremental testing is standard practice. Also, while we're close to the territory, investigate things like Test::More and building up a suite of unit tests that you can run to actually exercise the code and find errors - there are a lot of things that are perfectly valid syntactically, but will blow up horribly when actually being run.
| [reply] |
Re: Tool that detects perl syntax errors
by stonecolddevin (Parson) on Oct 31, 2005 at 21:45 UTC
|
Typically, unless it's just a warning, perl die's as soon as it encounters an error, thereby dissallowing the interpreter to check beyond the current error for other errors. I think this is nice, because it allows you to break down your code, and take care of problems bit by bit, as it should be :-)
| [reply] [d/l] |
Re: Tool that detects perl syntax errors
by QM (Parson) on Oct 31, 2005 at 21:57 UTC
|
I was wonder if there is a tool or module that can go over all the perl code and make a list of syntax errors.
<wish>
Once we get that, it should be only a short step to listing the logic errors too. If only...
</wish>
-QM
--
Quantum Mechanics: The dreams stuff is made of
| [reply] |
Re: Tool that detects perl syntax errors
by spiritway (Vicar) on Nov 01, 2005 at 03:32 UTC
|
There is an IDE called Komodo, put out by ActiveState. This displays errors before you run the code - as you type. In fact, it's annoying, because if you enter an opening parenthesis, quote, brace, etc., it flags everything as an error until you close the offending container. However, it is handy for catching most of the mistakes.
ActiveState has Windows and Linux versions of Komodo, and I've used it on both systems. There is a personal version for fairly little money, and a professional version for big bucks. However, the license for the product is to the user, so you can put this program on any computers you want, as long as you're the only one to use the program.
Komodo isn't perfect, and it's no substitute for careful planning and coding, but it does help catch those typos and other silliness we tend to do.
| [reply] |
|
|
| [reply] |