I agree that GetOpt::Std or GetOpt::Long are excellent (I use them often).
But if you want to roll your own you can treat @ARGV like any other array.

if (@ARGV)
   {  print "parameters present\n";
   }
else
   {  print "no parameters\n";
   }



-Andrew


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There are other caveats to be aware of as well when it comes to writing your
own switches.  I would recommend looking into the GetOpt::Std module that
comes standard with Perl.  It can do what you want and comes out much
cleaner.



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


_______________________________________________
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
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to