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

  2. From "perldoc perlsyn":
    The following compound statements may be used to control flow:
    if (EXPR) BLOCK
    [...]
    You are missing the mandatory paranthesis around the condition.

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

  3. Mark Richards

    patriknym Guest

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

    /Patrik
     
    patriknym, Nov 18, 2007
    #3

  4. 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, Nov 18, 2007
    #4
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.