misterperl has asked for the wisdom of the Perl Monks concerning the following question:
I researched using a variable as a sub name and found may examples with syntax like \$sub , &$sub , \&$sub, "do", "eval", even a seemingly unusual &{\&{$sub}}();
I can get some of these to work on a local sub, but not as part of my class object $A , trying syntax using those examples, like:
and like 27 other varieties. Can you (Rolf of course) suggest a syntax that works here?%$A->$ARGV[0]( $ARGV[1] ) $A->$ARGV[0]( $ARGV[1] ) %{$A->$ARGV[0]( $ARGV[1] ) } eval "$A->$ARGV[0]( $ARGV[1] )"; eval "{$A->$ARGV[0]( $ARGV[1] ) };" $A->\$ARGV[0]( $ARGV[1] )
TY!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How do I call a sub using a variable as its name, objectively
by choroba (Cardinal) on Oct 28, 2024 at 19:20 UTC | |
by etj (Priest) on Oct 29, 2024 at 14:48 UTC | |
Re: How do I call a sub using a variable as its name, objectively
by GrandFather (Saint) on Oct 28, 2024 at 20:39 UTC | |
by ysth (Canon) on Oct 28, 2024 at 23:21 UTC | |
by GrandFather (Saint) on Oct 29, 2024 at 05:23 UTC | |
Re: How do I call a sub using a variable as its name, objectively
by ikegami (Patriarch) on Oct 28, 2024 at 22:48 UTC | |
Re: How do I call a sub using a variable as its name, objectively
by SankoR (Prior) on Oct 28, 2024 at 19:23 UTC |