如何在 Perl 6 的命令行中传递任意参数列表?

How do I pass an arbitrary list of arguments on the command line in Perl 6?

我知道如何在命令行上将单个参数和命名参数传递给 Perl 6 脚本,但如何传递任意参数列表?

例如,

script.pl6 fileA.txt fileB.txt

然后 运行 它与

script.pl6 fileC.txt fileD.txt .. fileZ.txt

可以在 @*ARGS.

中找到原始命令行参数

您还可以使用带有 slurpy 参数的子 &MAIN,即

sub MAIN(*@args) { ... }

请注意,这将拒绝传递标志的调用。如果您也想捕获这些,请使用

sub MAIN(*@args, *%flags) { ... }