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

M

Mark Richards

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
 
J

Jürgen Exner

Mark said:
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
 
P

patriknym

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
 
T

Tad McClellan

Mark Richards said:
$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").
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top