12

In Perl 5, I was able to set an option multiple times like in this question:

Perl Getopt Using Same Option Multiple Times

I am wondering if it's possible to do the same with Perl 6 and the MAIN sub ?

Pat
  • 36,282
  • 18
  • 72
  • 87
Sebus
  • 430
  • 2
  • 10

1 Answers1

15

If you define your named parameters as an array then it just works :

perl6 -e 'sub MAIN( :@test ) { say @test }' --test=1 --test=2 --test=3
[1 2 3]
Scimon Proctor
  • 4,558
  • 23
  • 22
  • 1
    That's exact l'y what I was looking for. Perl6 have à lot of Nice features. I think I will use for developing my projet. Thank you very much ! – Sebus Aug 16 '18 at 20:24
  • 2
    No problem. I wasn't sure it would work. You should be able to apply constraints to the values too using a where clause. – Scimon Proctor Aug 16 '18 at 20:26