On Thu, Sep 26, 2002 at 07:30:37AM -0700, Admin-Stress wrote:
> I can use "if (scalar(@ARGV) < 3) {...}" but that not the case.
If the user executes the program like so:
program.pl foo bar
@ARGV will have 2 elements.
If the user executes the program like so:
program.pl "" "" ""
@ARGV will have three elements. Are you really trying to make sure the user
didn't try that, or are you just confused about how @ARGV is setup? If the
user does try the above do you really need to go to the extra effort to
verify that?
>How to detect "null" parameters? is "" equal to "null"?
In the first case, where the user typed:
program.pl foo bar
$ARGV[2] will be undef. So will $ARGV[3], $ARGV[4], and so on. @ARGV will
have 2 elements. undef has special properties that should have been
outlined in your learning material. These properties are described in
perldoc perldata. In short, undef is "" when compared to a string, and 0
when compared to a number.
In the second case, where the user typed:
program.pl "" "" ""
$ARGV[0] will eq "", $ARGV[1] will eq "", and $ARGV[2] eq "". $ARGV[3] and
beyond will all be undef. @ARGV will have 3 elements.
Does that answer your question?
Michael
--
Administrator www.shoebox.net
Programmer, System Administrator www.gallanttech.com
--
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]