我使用Getopt :: Long解析传递给我的程序的选项。我想格式化这些选项(在修改它们之后)以传递给另一个程序。使用Getopt :: Long解析的格式化选项传递给另一个程序
Getopt这样做还是可能有另一个模块可以为我做这个?
实施例:
use Getopt::Long qw(:config no_ignore_case);
# set defaults
my %ARG;
$ARG{config} = './default-config.ini';
$ARG{debug} = 0;
# process command line options
GetOptions(\%ARG, 'config|c=s', 'debug!');
# modify them as necessary
if (if $ARG{debug}) {
$ARG{config} = './debug-config.ini' ;
$ARG{debug} = 0;
$ARG{verbal} = 1;
}
# format options string to pass to other command
# expecting something like this in options string:
# '-config=./debug-config.ini --verbal'
$options_string = some_method_or_module_to_format(%ARG, 'config=s', 'verbal');
`some-other-script-1.pl $options_string`;
`some-other-script-2.pl $options_string`;
`some-other-script-3.pl $options_string`;
你能提供一个你想达到什么的简短代码示例吗? – hlovdal
如果您希望我们知道您的意思,您需要更具体地了解“格式”和“修改”的含义。 – TLP
我添加了一个例子。 –