Parse command-line arguments: Difference between revisions
m
→{{header|Raku}}: Undo bizarre single space indent that somebody found necessary to do
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
Thundergnat (talk | contribs) m (→{{header|Raku}}: Undo bizarre single space indent that somebody found necessary to do) |
||
Line 834:
(formerly Perl 6)
At the end of running any top-level code (which can preprocess the arguments if it likes), Raku automatically examines any remaining arguments and transforms them into a call to a <tt>MAIN</tt> routine, if one is defined. The arguments are parsed based on the signature of the routine, so that options are mapped to named arguments.
<syntaxhighlight lang="raku" line>sub MAIN (Bool :$b, Str :$s = '', Int :$n = 0, *@rest) {
say "Bool: $b";
say "Str: $s";
say "Num: $n";
say "Rest: @rest[]";
}</syntaxhighlight>▼
▲</syntaxhighlight>
{{out}}
<pre>$ ./main -h
|