[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Edlug Archive Jan 2003 ]

Re: [edlug] getopt in perl




A Zelter wrote:
Hi there,
Can any of you perl wizards out there tell me how I can get all the
command line options given to a program in one go.
e.g. If I call my perl program test.pl and at the command line type:
test.pl -a some randome stuff -p -q
I want to run test.pl and have the program grab the string of options so I
can do something with it. Basicaly my perl script is just going to run
another program, in this case uname, which is offending unison by giving
Linux as the operating system and not linux. I want it to run uname with
any other options it is given too and then parse the output and change
Linux to linux.

I use something like this:



use Getopt::Std;


$option_set = "h";		# valid option characters
&getopts($option_set) || die "$pn aborted: Incorrect option\n";
&help_info && exit(0) if $opt_h;

Dick

-----------------------------------------------------------------------
You can find the EdLUG mailing list FAQ list at:
http://www.edlug.org.uk/list_faq.html



This archive is kept by wibble@morpheux.org.DONTSPAMME
homepage