At work there is this entire testing system that is written in Perl and I am not exactly clear on how/what it does.. so if this question does not appear to be a Perl issue, it could very well be something to do with the testing system. Having said that, here is my question:

I have a series of functions that are called, and inside each of these functions an object is created from a common class. I use a reference to that object only inside the function where it is created.

When each of the functions are executed, the first one runs without any warnings, while all subsequent creations using the same class results in warnings about functions being re-defined.

And that is ok, I guess, since each creation of the object calls a series of eval statements that create a set of functions for setting and getting object values. But then again its not ok to me because I am confused as to why the pre-existing evals are still remembered. I thought that the evals were specific to that objects methods and when each function exited, the object as well as its dynamically created functions would be lost. Obviously this is not the case since the solution to this problem was to have a use statement that passed values to Class:MethodMaker.

But this now brings me to my question. What happened inside Perl that made the evals for the one object create entries for the entire namespace of that class? How does Perl handle evals that dynamically create functions, i.e. what are the steps that are taken to implement that. Or, where is there an existing explanation into the relative working parts of Perl?

Thank you for your attention and I understand if this explanation is lacking. Please feel free to ask me to clarify.

the_Don
...making offers others can't rufuse.


In reply to Redefined Methods.. ok, Why? by the_Don

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.