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

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

am 18.11.2007 17:36:04 von markmark

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

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

am 18.11.2007 17:40:00 von jurgenex

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

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

am 18.11.2007 17:43:07 von patriknym

On 18 Nov, 16:36, markm...@lycos.com (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

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

am 18.11.2007 18:01:08 von Tad McClellan

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/"

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

am 19.11.2007 10:48:14 von Abigail

_
Mark Richards (markmark@lycos.com) wrote on VCXCII September MCMXCIII in
:
** 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 !"

I guess you're trying to run perl6 code using a perl5 interpreter.

In perl5, we do write the expression following the 'if' inside parenthesis.



Abigail
--
$"=$,;*{;qq{@{[(A..Z)[qq[0020191411140003]=~m[..]g]]}}}=*_;
sub _ {push @_ => /::(.*)/s and goto &{ shift}}
sub shift {print shift; @_ and goto &{+shift}}
Hack ("Just", "Perl ", " ano", "er\n", "ther "); # 20071119