in reply to Creating sub from string without munging the symbol table

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^2: Creating sub from string without munging the symbol table
by stevieb (Canon) on Jun 22, 2015 at 18:31 UTC

    Your post *may* have been helpful for myself and future readers of this thread if you explained *why* not to do it, and or examples of code how to get around it, which is what my question was in the first place.

      I'm guessing sundialsvc4 read it as "create an entire subroutine from a string", when in reality you are asking only about "adding a subroutine to the symbol table using a string for the name"

Re^2: Creating sub from string without munging the symbol table
by Anonymous Monk on Jun 22, 2015 at 18:56 UTC

    Every function in every perl (or ruby or python or javascript or java) program is created from a string. The program source.

    And it is done using exactly the same parser as you invoke via eval.

Re^2: Creating sub from string without munging the symbol table
by Anonymous Monk on Jun 22, 2015 at 18:13 UTC
    sundialsvc4:

    I’m afraid that my mouth filled up with ... ahh, something that I politely just spit out ... when I read, “create a sub from a string.”

    D-O-N-’-T ... D-O ... T-H-A-T!

    ... in any programming language under the sun.

    well duh you gotta validate the strings first flushells