... but doesn't it also negate the symbol table-insertion techniques? The eval'd code will have to be parsed anew each time the sub is called.
Not so. The evals return code references which are stuffed into the package symbol table to make accessor methods; a subsequent call to the same method will find it and not call AUTOLOAD.

The purpose of the eval is to bind $field at the time AUTOLOAD happens. It does this as it is in the string passed to eval without an escape (all other variables are escaped). With the original, $field is not bound to a specific value, but forms a closure, and is bound to the calling pad (hence it will share values between instances). The eval solution gives you a fresh op tree each time AUTOLOAD is called.

--
I'm Not Just Another Perl Hacker


In reply to Re^5: Subroutines with differing behaviour created from AUTOLOAD by rinceWind
in thread Subroutines with differing behaviour created from AUTOLOAD by davis

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.