Date: 2009jun6
Language: perl
Q. How can I check the syntax of my perl script?
A. Just do:
perl -c <script>
perl -cw <script> - Also give warnings
perl -c myscript.pl (for example)
this compiles your script but does not run it.
A great way of making sure your perl scripts are at least sane.
It outputs:
myscript.pl syntax OK
or errors.
It does not check everything that you might expect a compiler to check, however.
It does not flag missing functions, eg:
missing_function();
will not cause an error. I guess this is because the syntax is correct but
calling a function is the same as:
main{'missing_function'}(); # approximate syntax
which you would not expect a compiler to check.
perl -cw <script> - Also give warnings