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

Discussion in 'Perl Misc' started by sonet, Jun 14, 2007.

  1. sonet

    sonet Guest

    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?
     
    sonet, Jun 14, 2007
    #1
    1. Advertising

  2. 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
     
    Jürgen Exner, Jun 14, 2007
    #2
    1. Advertising

  3. sonet

    Guest

    On Jun 14, 10:04 am, "Jürgen Exner" <> 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.
     
    , Jun 14, 2007
    #3
  4. On Jun 14, 5:15 am, "sonet" <> 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".
     
    Brian McCauley, Jun 14, 2007
    #4
  5. <> wrote:
    > On Jun 14, 10:04 am, "Jürgen Exner" <> 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/"
     
    Tad McClellan, Jun 14, 2007
    #5
  6. sonet

    Guest

    On Jun 13, 10:04 pm, "Jürgen Exner" <> 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
     
    , Jun 17, 2007
    #6
  7. wrote:
    > On Jun 13, 10:04 pm, "Jürgen Exner" <> 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
     
    Jürgen Exner, Jun 17, 2007
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nikolay Petrov

    Runing Client-side code

    Nikolay Petrov, Mar 22, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    621
    Jason Mauss
    Mar 24, 2005
  2. Replies:
    1
    Views:
    517
    Larry
    Mar 7, 2006
  3. Thomas
    Replies:
    2
    Views:
    1,927
    Peter van Merkerk
    Sep 2, 2003
  4. mg
    Replies:
    0
    Views:
    127
  5. Jonathan Heinen

    Runing ruby on rails code from console?

    Jonathan Heinen, May 24, 2006, in forum: Ruby
    Replies:
    2
    Views:
    84
    Jonathan Heinen
    May 25, 2006
Loading...

Share This Page