Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

raku

I know how to pass single and named arguments on the command line to a Perl 6 script, but how do I pass an arbitrary list of arguments?

For example,

script.pl6 fileA.txt fileB.txt

and then run it with

script.pl6 fileC.txt fileD.txt .. fileZ.txt
like image 291
CyberSkull Avatar asked Jan 05 '16 07:01

CyberSkull


1 Answers

The raw commandline arguments can be found in @*ARGS.

You can also use a sub &MAIN with a slurpy parameter, ie

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

Note that this will reject invocations that pass flags. If you want to capture those as well, use

sub MAIN(*@args, *%flags) { ... }
like image 119
Christoph Avatar answered Oct 15 '22 16:10

Christoph