Dave's Brain

Browse - programming tips - syntax check perl program

Date: 2009jun6
Language: perl

Q.  How can I check the syntax of my perl script?

A.  Just do:

	perl -c <script>

	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.
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2012, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.
Advertisements: