This question has been discussed by someone already:
How can I elegantly call a Perl subroutine whose name is held in a variable?. But it doesn't answer the question completely. Actually I have the following code. It works but looks a bit ugly:
if ( defined &{ "some::cool::${module}::method" } ) {
&{ \&{ "some::cool::${module}::method" } }(some arguments);
} else {
...
}
I can check the method availability as below but don't know how to proceed further in term of my question:
if ( "some::cool::${module}"->can("method") ) {
???