Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Perl Syntax check

by alandev (Scribe)
on Jul 12, 2006 at 10:20 UTC ( [id://560649] : perlquestion . print w/replies, xml ) Need Help??

alandev has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Perl Syntax check
by bart (Canon) on Jul 12, 2006 at 10:55 UTC
    (Use the -e command line switch, then you can run and test perl syntax entered in the command line.)

    You can enable strict and warnings on the command line. That ought to fix it fix it.

    perl -cw -Mstrict -e "Welcome Back"
    yields:
    -e syntax OK
    
    Oops. It works with a single word:
    perl -cw -Mstrict -e Welcome
    Bareword "Welcome" not allowed while "strict subs" in use at -e line 1.
    -e had compilation errors.
    
    But with two words, it's problematic:
    perl -MO=Deparse -e "Welcome Back"
    produces:
    'Back'->Welcome;
    -e syntax OK
    
    Syntaxwise, it's OK, even under strict.

    This is the so-called indirect object syntax, which often is problematic as it doesn't always work as intended. I wish strict had a way to disallow it.

      thanks for the suggestion :)
Re: Perl Syntax check
by gellyfish (Monsignor) on Jul 12, 2006 at 11:06 UTC

    Barewords which do not otherwise cause a syntax error only give rise to an error when strict 'subs' is in operation, thus you will need to do something like:

    perl -Mstrict=subs -c file.pl
    I have limited this just to the 'subs' stricture because I don't know anything else about the code that you are accepting.

    Of course this might not be what you are asking at all.

    /J\

Re: Perl Syntax check
by davorg (Chancellor) on Jul 12, 2006 at 10:30 UTC
    $ perl -c "Welcome Back" Can't open perl script "Welcome Back": No such file or directory

    I'm not at all sure what it is that you're asking. Can you be a little more explicit please.

    --
    <http://dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

    A reply falls below the community's threshold of quality. You may see it by logging in.