hi brassbin,
*as if the sub was called 3 times, how do i make it so that all 3 values of the option are passed to @_ once with one invocation of the subroutine?
Ultimate control over what should be done when (actually: each time) an option is encountered on the command line can be achieved by designating a reference to a subroutine (or an anonymous subroutine) as the option destination. When GetOptions() encounters the option, it will call the subroutine with two or three arguments. The first argument is the name of the option. (Actually, it is an object that stringifies to the name of the option.) For a scalar or array destination, the second argument is the value to be stored...
And if I get that right something like this:NOTE: If the is less than what is specified, you get a message of Insufficient arguments for option ....use warnings; use strict; use Getopt::Long; GetOptions('test=s{3}'=>\&sub1); sub sub1{ print $_[1]; }
In reply to Re: Getopt::Long subroutine question
by 2teez
in thread Getopt::Long subroutine question
by brassbin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |