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
|
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|