in reply to using a variable with require
Another couple alternatives for executing a subroutine in a package determined at run time:
If it can be invoked as a static method, $name->somesub() will work.
In the general case, $name->can( 'somesub' )->() will also work. If you need to call somesub() more than once,
my $somesub = $name->can( 'somesub' ); $somesub->();
|
|---|