I would like to set a series of magic numbers from the command line.

I have in a program

constant N-SCENARIOS = 10;

which works great. But I would like to set an option in the command line, such as
perl6 program.p6 scenarios=15

and then within program have the option assigned to the constant.

I tried this with a BEGIN block, something like

  if @*ARGS[0] ~~ / scenarios \= (.d+) / { constant N-SCENARIOS = $0 }


But this does not work.

I could have a normal scalar
my $scenarios ;

But that doesn't seem as elegant as creating a constant.

Any neat trick I am missing?


Reply via email to