dr_jkl has asked for the wisdom of the Perl Monks concerning the following question:
Using Getopt::Long, I would like to have a non-option argument which is unaffected by surrounding options (my options in this case will be mostly switches).
The way I usually handle options is like this:my %opt =( shell => "bash", foo => "/some/path", input => undef, # yes, i know this doesn't need to be here ); GetOptions(\%opt, 'shell=s', 'foo=s', 'bip', 'bar', 'baz' );
How can I integrate a non-option argument in this code? Preferably, I would like the argument to be set as $opt{input} so I can act on it one way or another depending on which of the options (bip, bar, baz, or nothing at all) is selected.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: non-option argument question
by ikegami (Patriarch) on Sep 12, 2012 at 05:16 UTC | |
|
Re: non-option argument question
by kcott (Archbishop) on Sep 12, 2012 at 05:23 UTC | |
by dr_jkl (Acolyte) on Sep 12, 2012 at 06:16 UTC | |
by kcott (Archbishop) on Sep 12, 2012 at 08:36 UTC | |
by dr_jkl (Acolyte) on Sep 12, 2012 at 19:41 UTC |