in reply to How to make a variable in hard call.
You could use string eval, if I understand your question correctly.
use strict; use warnings; use Test::More; sub square { my $num = shift; return $num*$num; } my $subname = 'square'; is( eval "&$subname(4)", 16 ); done_testing;
Hope this helps!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to make a variable in hard call.
by ikegami (Patriarch) on May 09, 2023 at 08:24 UTC | |
|
Re^2: How to make a variable in hard call.
by SankoR (Prior) on May 08, 2023 at 01:31 UTC |