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

In reply to Re: Function templates done right by vladb
in thread Function templates done right by drix

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.