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'})->();
In reply to Re: using a variable with require
by haukex
in thread using a variable with require
by geoffleach
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |