This worked for me:
use strict;
sub foo {
print "inside main foo ($_[0])\n";
}
sub bar {
print "inside main bar ($_[0])\n";
}
foreach my $sub (qw(foo bar)) {
$main::{$sub}->($sub);
}
OUTPUT:
-----
inside main foo (foo)
inside main bar (bar)
-----
In case of $self->SUPER::$funcName(@_), I guess you could try $self->SUPER{$funcName}->(@_)?
The trick is you can't just write something like $main::$sub_name(), but have to go the $main::{$sub}->(@args) way instead. This works since $main::{$sub} would return a typeglob for the name '$sub', and when you apply () operator to that typeglob, appropriate subroutine will be invoked.
"There is no system but GNU, and Linux is one of its kernels." -- Confession of Faith
|