in reply to Perl Syntax check

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

Replies are listed 'Best First'.
Re^2: Perl Syntax check
by alandev (Scribe) on Jul 12, 2006 at 11:13 UTC
    thanks for the suggestion :)