in reply to using a variable with require
See the core module Module::Load (there are others, like Module::Runtime, but this one is core), plus the \&{'subname'} symbolic reference syntax which is allowed even under strict. However, if $name is user input, this is still a security risk!
use warnings; use strict; use Module::Load qw/load/; my $name = 'SomeModule'; load $name; (\&{$name.'::somesub'})->();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: using a variable with require
by geoffleach (Scribe) on Jun 22, 2022 at 13:20 UTC |