Syntax error? What syntax error? Assignment fo default values?

Discussion in 'Perl Misc' started by Mark Richards, Nov 18, 2007.

  1. When I run the following piece of code:

    if !defined( $ARGV[ 1 ] ) {
    if !defined( $ARGV[ 0 ] ) {
    $mypath = '\\'; }
    mydepth = 1; }

    then I am getting the following error:

    syntax error at du_cb.pl line 19, near "if !"
    Execution of du_cb.pl aborted due to compilation errors.

    Where is the syntax error? Even if I replace ' by " it does not work.

    As you can imagine I want to assign default values if I don't pass special, individual parms.

    How can I do this otherwise?

    Mark
     
    Mark Richards, Nov 18, 2007
    #1
    1. Advertising

  2. Mark Richards wrote:
    > When I run the following piece of code:
    >
    > if !defined( $ARGV[ 1 ] ) {
    > if !defined( $ARGV[ 0 ] ) {
    > $mypath = '\\'; }
    > mydepth = 1; }
    >
    > then I am getting the following error:
    >
    > syntax error at du_cb.pl line 19, near "if !"
    > Execution of du_cb.pl aborted due to compilation errors.


    From "perldoc perlsyn":
    The following compound statements may be used to control flow:
    if (EXPR) BLOCK
    [...]

    > Where is the syntax error?


    You are missing the mandatory paranthesis around the condition.

    jue
     
    Jürgen Exner, Nov 18, 2007
    #2
    1. Advertising

  3. Mark Richards

    Guest

    On 18 Nov, 16:36, (Mark Richards) wrote:
    > When I run the following piece of code:
    >
    > if !defined( $ARGV[ 1 ] ) {
    > if !defined( $ARGV[ 0 ] ) {
    > $mypath = '\\'; }
    > mydepth = 1; }
    >
    > then I am getting the following error:
    >
    > syntax error at du_cb.pl line 19, near "if !"
    > Execution of du_cb.pl aborted due to compilation errors.
    >
    > Where is the syntax error? Even if I replace ' by " it does not work.
    >
    > As you can imagine I want to assign default values if I don't pass special, individual parms.
    >
    > How can I do this otherwise?
    >
    > Mark


    if ( !defined $ARGV[ 1 ] ) {
    if ( !defined $ARGV[ 0 ] ) {
    $mypath = '\\'; }
    $mydepth = 1; }

    /Patrik
     
    , Nov 18, 2007
    #3
  4. Mark Richards <> wrote:

    > $mypath = '\\'; }



    You can probably use sensible directory separators instead:

    $mypath = '/'; }

    Forward slashes work fine on Windows (they don't work fine only
    in the Windows "shell").

    --
    Tad McClellan
    email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
     
    Tad McClellan, Nov 18, 2007
    #4
    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. Denis Remezov
    Replies:
    4
    Views:
    369
  2. sosman
    Replies:
    1
    Views:
    351
    Duncan Booth
    Jul 20, 2004
  3. nagy
    Replies:
    36
    Views:
    1,041
    Terry Reedy
    Jul 20, 2006
  4. Chris
    Replies:
    34
    Views:
    1,565
  5. puzzlecracker
    Replies:
    8
    Views:
    446
    James Kanze
    Apr 15, 2008
Loading...

Share This Page