You could use sub references instead:
@listofsubs = (\&sub1, \&sub2, \&sub3);
foreach $sub (@listofsubs)
{
$sub->();
}
Or you might be doing this on objects:
foreach $sub (@listofsubs) {
$self->$sub()
}
Or you could just try to find them... if they're in the current package, this might work (untested):
foreach $sub (@listofsubs) {
if (not ref $sub)
{
$sub = __PACKAGE__->can($sub);
}
$sub->();
}
(by checking if it's a ref, you could comingle names and code-refs:
@listofsubs = ('sub1', \&sub2, sub { do_stuff() }); - the object example can handle this, too, only better.)