> -----Original Message-----
> Behalf Of Dirk Bremer
> 
> 
> $#ARGV contains the number of arguments minus one in @ARGV, i.e. 
> the first argument is $ARGV[0]. Sample code:
> 
>     # Check that the required number of arguments have been passed.
>     if ($#ARGV < 0)
>     {
>         Help();
>         $InputFile = GetUserInput('Enter the input filename',0);
>     }
>     else {$InputFile = $ARGV[0];}
> 
>     # Check for optional second argument.
>     if ($#ARGV > 0) {$NbrPages = $ARGV[1];}
> 
>     # Check for optional third argument.
>     if ($#ARGV > 1) {$Width = $ARGV[2];}
>     else {$Width = 80}
> 

Alternatively...

    my($InputFile, $NbrPages, $Width) = @ARGV;

    # Check that the required number of arguments have been passed.
    if (!defined $InputFile or $InputFile eq "")
    {
        Help();
        $InputFile = GetUserInput('Enter the input filename',0);
    }

    # Check for optional second argument (make sure it is undef.)
    ($NbrPages = undef) if (defined $NbrPages and $NbrPages eq "");

    # Check for optional third argument.
    ($Width = 80) if (!defined $Width or $Width eq "");

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to