Perl6:如何在运行线上读取混合参数?

问题描述 投票:1回答:1

我一直从运行线运行程序,这些程序使您可以混合运行线参数的顺序。如果您在混合中添加其他内容,它们会抓住您。例如:

$ xxx -r abc -q def -w xyz

$ xxx -w xyz -q def -r abc

他们如何做到的?为此有一些模块吗?

非常感谢,

-T

perl6 raku
1个回答
0
投票

这里是使用Getopt::Long的示例:

use v6;
use Getopt::Long;

my %opt = help => 0, 'r=s' => "", 'q=s' => "", "w=s" => "";
my %options = get-options(%opt).hash;
say %options;

示例运行:

$ p.p6  -w xyz -q def -r abc
{help => 0, q => def, r => abc, w => xyz}
© www.soinside.com 2019 - 2024. All rights reserved.