Guildencrantz has asked for the wisdom of the Perl Monks concerning the following question:
I don't know if it's just late or I'm actually losing my mind.
I am trying to verify that the user is actually passing a parameter to a script.
the script would be called traditionally: "./scriptNAME parameter"
in the script I was then attempting to check and see if there was anythnig in @_ (hence a parameter was passed). I was doing this with:
if($#_) { do stuff } else { print "Bad user. Input parameter.\n"; }
The thing is that no matter what I call (ie: "./scriptNAME" or "./scriptNAME parameter") $#_ is always -1. I am not using shift before the test, merely a few global definitions (mysql login information, but it's all explicitly defined, none is being generated by the script).
Thanks for the support, sorry if I am just having a mental fart.
~~Guildencrantz
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Test for parameters?
by chromatic (Archbishop) on Mar 27, 2003 at 07:59 UTC | |
by Guildencrantz (Sexton) on Mar 27, 2003 at 08:04 UTC | |
by Coruscate (Sexton) on Mar 27, 2003 at 08:12 UTC | |
|
Re: Test for parameters?
by robartes (Priest) on Mar 27, 2003 at 08:07 UTC |