in reply to Re: How do I call a sub using a variable as its name, objectively
in thread How do I call a sub using a variable as its name, objectively

Or use a whitelist:
my $A = My::->new(); my $method = $method_list{$ARGV[0]} or die "Invalid method $ARGV[0]."; $A->$method(@ARGV[1..$#ARGV]);
--
A math joke: r = | |csc(θ)|+|sec(θ)| |-| |csc(θ)|-|sec(θ)| |
  • Comment on Re^2: How do I call a sub using a variable as its name, objectively
  • Download Code

Replies are listed 'Best First'.
Re^3: How do I call a sub using a variable as its name, objectively
by GrandFather (Saint) on Oct 29, 2024 at 05:23 UTC

    I have done that in the past, but the list, the implementation and the documentation all have to be updated. Using the prefix trick avoids the need to update the list. I admit, a fairly minor point, but it does reduce scope for error.

    Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond