Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

does a scaler conatin '-'

Status
Not open for further replies.

jamsman

Technical User
Jul 22, 2005
38
DE
hi simple question i am allowing the user to supply options to my script from the command line:

myscript.pl -abc INputone Inputtwo

the options are signified by the - sign it is possible for the user to not enter any options too

how do i see if $ARGV[0] contains the - and therefore is the options and not Inputone

thank you
 
Why don't you look at Getopt::Std and Getopt::Long.
These modules do all that tedium for you.



Trojan.
 
thanks for the advice but the script will be distributed to many boxes each with different installations of perl soi want to keep the module use to a minimum

thanks
 
I think you'll find that these modules are part of the standard installation and therefore will always be there.


Trojan.
 
ok thanks even on hold versions of perl (5)
 
if you mean old versions then yes.
You can always test if a module exists in your installation like this:
Code:
perl -e 'use Getopt::Std;'
If it comes back with errors (cannot find module) then you know you don't have it.
If it just returns with a prompt then you have it already.


Trojan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top