May be I am not phrasing this question properly. In a nutshell, I expect one argument to be pased to the script. However, I am doing the checking for it in a sub, which eventually receives this argument.
So, I blatently pass $ARGV[0] to the sub regardless of whether any arguement was passed to the script or not. I do the checking of # of arguments in the sub (May be not the right place to do so). I actually exected @_ to contain no entries. Yet, it contains 1. But the retrieved value using shift is undefined.
So, here is my academic curiosity question:#! /usr/bin/perl use strict; use warnings; sub p1 { my $n1; $n1=@_; print "1. Parameters to the sub p1 $n1\n"; my $p1=shift; print "2. p1=$p1\n"; } p1 $ARGV[0];
Arguments is Perl are passed by reference. Argument $ARGV[0] never existed in memory (If I did not pass anything argument to the script), so there is no address for it. So shouldn't @_ say 0? How else would you (recommend) check for passed arguments to be present if this does not work?
Thanks.
Ash
In reply to Question: Is undef a valid argument? by jujiro_eb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |