Glenn writes..

>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.

Yes, there's a better way. Two modules: Getopt::Long and Getopt::Std,
they ship with ActivePerl - check your doco for more information. BUT,
while I do recommend them, they are not necessary to fix your current
problem (see below).

>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; }

You need to make sure that $ARGV[0] is initialised before using it in
your 'ne' test. Your code should be like this:

  if( defined $ARGV[0] && $ARGV[0] ne "") { do stuff; }

-- 
  Jason King
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to