How to check the perl's syntax error before runing the code?

S

sonet

How to check the perl's syntax error but does not execute it?
The eclipse (PERL EPIC Project) can check the perl's syntax
error when the code does not in runtime.

And it support source format the perl's code.Have any rules
can do that?
 
J

Jürgen Exner

sonet said:
How to check the perl's syntax error but does not execute it?

Trivial. Did you check the documentation of perl?
From "perldoc perlrun":
-c causes Perl to check the syntax of the program and then exit
without executing it. [...]

jue
 
R

ramesh.thangamani

sonet said:
How to check the perl's syntax error but does not execute it?

Trivial. Did you check the documentation of perl?
From "perldoc perlrun":
-c causes Perl to check the syntax of the program and then exit
without executing it. [...]

jue


Also using the option -w will be useful in checking the warnings.
 
B

Brian McCauley

How to check the perl's syntax error but does not execute it?

Sorry this is impossible.

You can use -c which causes the perl compiler to exit at the point
just before it starts to execute the main body of the script.

However, at this point any code in BEGIN and CHECK blocks will already
have been executed.
The eclipse (PERL EPIC Project) can check the perl's syntax
error when the code does not in runtime.

It is impossible to fully check the syntax of Perl code without
allowing it to execute. This is a known problem with Perl5. In
principle you could run perl -c in a chroot shadbox. I don't know if
eclipse does this.
And it support source format the perl's code.Have any rules
can do that?

Yes, look at Perl the syntax highlighting rules in any popular open-
source programmers' editor. However these rules are only approximate
because "only perl can parse Perl".
 
T

Tad McClellan

sonet said:
How to check the perl's syntax error but does not execute it?

Trivial. Did you check the documentation of perl?
From "perldoc perlrun":
-c causes Perl to check the syntax of the program and then exit
without executing it. [...]

jue


Also using the option -w will be useful in checking the warnings.


You don't need the -w switch if you have enabled lexical warnings
in your code (and you should have).
 
A

asimsuter

sonet said:
How to check the perl's syntax error but does not execute it?

Trivial. Did you check the documentation of perl?
From "perldoc perlrun":
-c causes Perl to check the syntax of the program and then exit
without executing it. [...]

jue


There are cases where -c will say that syntax is OK yet it will fail
at runtime.

Classic cases:

1) missing 'use Library'
2) missing sub Function definition.

Regards.
Asim Suter
(e-mail address removed)
 
J

Jürgen Exner

sonet said:
How to check the perl's syntax error but does not execute it?

Trivial. Did you check the documentation of perl?
From "perldoc perlrun":
-c causes Perl to check the syntax of the program and then exit
without executing it. [...]

jue


There are cases where -c will say that syntax is OK yet it will fail
at runtime.

Classic cases:

1) missing 'use Library'
2) missing sub Function definition.

Neither is a syntax issue and the OP explicitely asked for a syntax check.

jue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top