|
Posted by Jim Gibson on February 28, 2008, 2:47 pm
Please log in for more thread options In article
> > 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. :-(
That is why it is always best to post a *complete* program, not just a
code fragment. Compilers are not always very good about diagnosing the
source of errors and identifying the exact line where the error is
located.
--
Jim Gibson
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
|