> My question pertains to using command line variables in Perl.
> I created a script that uses SQL and runs from an application, and the
only
> parameter is optional.  This script works well when the parameter is
> required or not used at all.
> I have altered the SQL script so that it can accept a variable or
execute
> the query without it, but I need to do the same in Perl.
>
> I am using @ARGV and explicitly assigning it to a variable.  Below is
an
> excerpt:
> if (defined(@ARGV[1]))
> {
> $filename = @ARGV[1];
> $sth->execute($filename) || die "Couldn't execute statement
> " . $sth->errstr;
>
> This is my first script, so I have been reading, researching and
testing
> what I find. However, I found nothing about this anywhere.
>
>
> Please help!

And your question?

(I'll take a guess and note that your syntax above isn't
doing what you probably think you are doing. Try:

    if (defined($ARGV[0]))
    {
        $filename = $ARGV[0];
        $sth->execute($filename) || die "Couldn't execute statement" .
$sth->errstr;

Note the use of $ not @, and 0 not 1.

hth

Reply via email to