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
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) { ... }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With