How to require 1 or more of an argument in MAIN

  • A+
Category:Languages

Right now, I have a MAIN sub that can take one or more string arguments. But I am using two separate parameters for MAIN to do it:

sub MAIN (     Str:D $file,     *@files, ) {     @files.prepend: $file;      # Rest of the program } 

Now I am wondering if there's a more idiomatic way to achieve this, as my current solution feels a little clunky, and not very Perly.


You could do it with a proto sub

proto sub MAIN ( $, *@ ){*}  multi sub MAIN ( *@files ) {     # Rest of the program } 

or with sub-signature deparsing

sub MAIN ( *@files ($,*@) ) {     # Rest of the program } 

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: