Re: code help



On Feb 27, 10:31 pm, "John W. Krahn" <some...@xxxxxxxxxxx> wrote:
jammer wrote:
Why does this give a syntax error?

There is no syntax error there.

# not 2 arguments, print usage
if ($#ARGV != 1) {

That's a great way to confuse a newby.  Why does the comment say "2
arguments" but you are comparing the variable to 1?  Try it like this:

# not 2 arguments, print usage
if ( @ARGV != 2 ) {

        print "\nusage: " . $ARGV[0] . "\[backupDir\] \

Unlike C, Python, etc. the first argument of @ARGV is *not* the program
name, you want the $0 variable instead.

I had a missing semi-colon and the error pointed to that block. :-(
.



Relevant Pages

  • Re: code help
    ... jammer wrote: ... There is no syntax error there. ... That's a great way to confuse a newby. ...
    (comp.lang.perl.misc)
  • Re: What is the better method for using hash??
    ... I'd do it by measuring their memory usages, ... then comparing them. ... hashes (and is also a syntax error if you use strict). ...
    (comp.lang.perl.misc)
  • Re: date comparioson in a Case statement
    ... Both "NA" and e_dt have to be the same datatype. ... > I have a case statement where I am comparing two dates ... > Syntax error during implicit conversion of VARCHAR value 'NA' to a ...
    (microsoft.public.sqlserver.programming)