So far as arrays are introduced, it is a good time to meet one of the built-in arrays,
* in its name is the second sigil, or twigil, and we’ll see more of them in the future. But for now, let’s get the advantages of using that special array. It contains the arguments that the program gets from the command line.
Consider the following program run:
$ raku run.raku alpha beta
run.raku gets two parameters:
beta. They can be read from
say @*ARGS.elems; say @*ARGS; say @*ARGS;
This program prints the number of arguments passed to it and the arguments themselves:
$ raku run.raku alpha beta 2 alpha beta
Notice that the program requires no change if you call it as an executable file:
$ ./run.raku alpha beta
The program, in this case, should have a shebang, but the most important thing is that the indices of
@*ARGS still start with
#!/usr/bin/env raku say @*ARGS.elems; say @*ARGS; say @*ARGS;
Complete the quiz that covers the contents of this topic.
💪 Or jump directly to the exercises to this section.