I'll second sauoq's recommendation that you redesign this. You are hitting the kind of maintainance problems that will make this a nightmare, and it's not even written yet.

Wherever you want to use a symbolic reference (sub foo;$bar="foo"; &$bar), use a real one instead (sub foo;$bar=\&foo;). That solves the problem of not finding the sub from a name. If you want to select them with strings, put them into a hash keyed by the name.

If you want to change your program logic by changing the meaning of subroutines, there are formal methods to help you. OO has you do it by calling generic methods of an object and relying on the object to know its own implementations. State machines would have you carefully define the allowed combinations of function and make transitions between function sets all at once, with guarantees that intermediate and invalid states are not accessible.

Some procedural logic may be the best way to simplify this code, too. I confess that I have no firm idea what your code is supposed to do. Am I right that you want a subroutine to know what what the invoking references to it used to point to? That threw me.

After Compline,
Zaxo


In reply to Re: Symbolic reference to a subroutine by Zaxo
in thread Symbolic reference to a subroutine by UncleRon

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.