Re: getting arguments
- From: kens <kenslaterpa@xxxxxxxxxxx>
- Date: Sat, 28 Jul 2007 13:53:30 -0700
On Jul 28, 4:49 pm, kens <kenslate...@xxxxxxxxxxx> wrote:
On Jul 28, 4:01 pm, "fry...@xxxxxxxxx" <fry...@xxxxxxxxx> wrote:
Hi there
I want to run my per script with arguments, for instance:
./script.pl -one value one text 1 -two value two text 2 -three value
three text 3
and i want to get those arguments in
$one = value one text 1
$two = value two text 2
$three = value three text 3
i tried with regular expression m/-one (.+?) -two (.+?) -three (.+?)/
and it works but when i mix-up arguments like:
./script.pl -two value two text 2 -three value three text 3 -one value
one text 1
then i need to use different regex.
Someone know other solution ?
Thanks in advance
Take a look at the Getopt::Long module.
perldoc Getopt::Long
Note that if there are spaces in the option strings, they will have to
be quoted on the command line.
For example, ./script.pl -two "value two text 2" -three "value three
text"
HTH, Ken
Of course that example should have been :
../script.pl --two "value two text 2" --three "value three text"
Have to use double dashs before the option if it is not a single
character.
Ken
.
- References:
- getting arguments
- From: frytaz@xxxxxxxxx
- Re: getting arguments
- From: kens
- getting arguments
- Prev by Date: Re: getting arguments
- Next by Date: Re: getting arguments
- Previous by thread: Re: getting arguments
- Next by thread: Re: getting arguments
- Index(es):