Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to check the perl's syntax error before runing the code?

Reply
Thread Tools

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

 
 
sonet
Guest
Posts: n/a
 
      06-14-2007
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?



 
Reply With Quote
 
 
 
 
Jürgen Exner
Guest
Posts: n/a
 
      06-14-2007
sonet wrote:
> 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


 
Reply With Quote
 
 
 
 
ramesh.thangamani@gmail.com
Guest
Posts: n/a
 
      06-14-2007
On Jun 14, 10:04 am, "Jürgen Exner" <(E-Mail Removed)> wrote:
> sonet wrote:
> > 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.

 
Reply With Quote
 
Brian McCauley
Guest
Posts: n/a
 
      06-14-2007
On Jun 14, 5:15 am, "sonet" <(E-Mail Removed)> wrote:

> 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".


 
Reply With Quote
 
Tad McClellan
Guest
Posts: n/a
 
      06-14-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) <(E-Mail Removed)> wrote:
> On Jun 14, 10:04 am, "Jürgen Exner" <(E-Mail Removed)> wrote:
>> sonet wrote:
>> > 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).


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
 
Reply With Quote
 
asimsuter@hotmail.com
Guest
Posts: n/a
 
      06-17-2007
On Jun 13, 10:04 pm, "Jürgen Exner" <(E-Mail Removed)> wrote:
> sonet wrote:
> > 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 Removed)

 
Reply With Quote
 
Jürgen Exner
Guest
Posts: n/a
 
      06-17-2007
(E-Mail Removed) wrote:
> On Jun 13, 10:04 pm, "Jürgen Exner" <(E-Mail Removed)> wrote:
>> sonet wrote:
>>> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
error runing ant in eclipse ant view yihucd@gmail.com Java 1 03-07-2006 08:39 PM
error: syntax error before '*' token Manuel C++ 3 01-12-2006 02:59 PM
error C2143: syntax error : missing ';' before '*' kalpana.sinduria@patni.com C++ 2 12-14-2004 01:54 PM
Get confirmation from popup before runing code in event handler mg ASP .Net Web Controls 0 05-01-2004 04:36 PM



Advertisments