jobi has asked for the
wisdom of the Perl Monks concerning the following question:

Masterly Mindful Monks,

The following code is what this novice has managed to glean from reading The Holy Perldoc referencing references.

Now, the question that's eluding the novice's mind is whether 'tis possible to rid the code of that annoying my $coderef = \&$_; line, and do the referencing/dereferencing in one fell swoop?

This novice realizes that this could be done by banishing the line use strict; from the code, but that beautiful flower should really be kept blossoming in the garden of the Monastery, and not be trampled down needlessly.

foreach my $MySubName (@list) {
## &{\&$MySubName}($MySubName); # This works!
## $::{$MySubName}($MySubName); # This (tmoertel) is better.
no strict qw(refs);
&{*$MySubName}($MySubName); # Use GLOB - Also cool!
#Chromatic's OO way --
#can(METHOD)
# can checks to see if its object has a method called METHOD,
# if it does then a reference to the sub is returned, i
# if it does not then undef is returned.
# main->can($MySubName)->($MySubName);
}

I wouldn't really call that an OO way. Sure, it uses can as a class method on main, but that's where the OOishness ends. It returns a plain coderef and executes it with a different dereferencing syntax than you used. I believe it is also the only alternative that does not use a symbolic reference.

Do yourself a favour and implement a dispatch table. This additional
level of indirection may seem a maintenance burden, but it will sure
pay off in the long run. You will know exactly when and why it's failing,
and you will also minimize the risk of malicious code injection.

Don't just cut and paste my code. I don't have the slightest idea
about what you're trying to do with your program. The code above is
not substitute for your own judgement.

P.S.
If you decide to use symbol tables instead of plain hashes for lookup, as other
people have suggested in this thread, try to use a separate namespace
for this purpose and not main::. "Whitelisting" is
important from a security perspective.

Thank you for your sage advice, this novice did have in mind to implement some form of dispatch table in the actual project code, but your sketch makes a few points this novice most certainly wouldn't have thought about on his own.

You want to call a subroutine by the name in a variable, which is disallowed by strict 'refs'. One of the values of strictness is that if strictness is turned off in one part of some code that is otherwise compliant, it is a useful warning to the reader that dangerous stuff is happening here - rather than hide it, highlight it:

for my $subname (@list) {
# we have to turn of strict 'refs' here because ...
# but it is safe to do so because ...
no strict 'refs';
$subname->($subname);
}