I would recommend using Getopt::Simple or Getopt::Long
-----Original Message----- From: Wagner, David --- Senior Programmer Analyst --- WGO [mailto:[EMAIL PROTECTED]] Sent: Monday, January 27, 2003 4:58 PM To: 'Glenn Meyer'; [EMAIL PROTECTED] Subject: RE: Detecting $ARGV[0] Glenn Meyer wrote: > Is there a better way to detect a parameter given in a command line? > For example, to run the script (obviously) c:\>script.pl I have > also added some "switches" to help with setup of the options (like) > c:\>script.pl /h to see a help message > c:\>script.pl /i to generate a new options file, etc. And it is > all working well. > > Question: When NOT using a switch (just running the script), I am > getting a message I would like to supress or preferable fix by using > more correct code... > Use of uninitialized value in string ne at logsaver.pl line 33. > > This is of course because I have not included a /h or /i value. The > script runs, but I would prefer it ran cleanly with no message. > > Code is this.... > # if no parameters passed, skip. If something passed, then do. > if($ARGV[0] ne ""){ do this stuff; } > > Thank you! > > > Glenn Meyer change from if($ARGV[0] ne ""){ do this stuff; } to if( defined $ARGV[0] && $ARGV[0] ne ""){ do this stuff; } Wags ;) ********************************************************** This message contains information that is confidential and proprietary to FedEx Freight or its affiliates. It is intended only for the recipient named and for the express purpose(s) described therein. Any other use is prohibited. **************************************************************** _______________________________________________ Perl-Win32-Admin mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs _______________________________________________ Perl-Win32-Admin mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs