Re: code help
- From: "John W. Krahn" <someone@xxxxxxxxxxx>
- Date: Thu, 28 Feb 2008 03:31:57 GMT
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.
[backupConfigFile\]\n";
}
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
.
- Follow-Ups:
- Re: code help
- From: jammer
- Re: code help
- References:
- code help
- From: jammer
- code help
- Prev by Date: Re: code help
- Next by Date: Re: Converting "’" to an Apostrophe?
- Previous by thread: Re: code help
- Next by thread: Re: code help
- Index(es):