That's exactly what I want to do -- thank you for your understanding my question! However ... (sigh),... how can I do it without explicitly passing "__PACKAGE_" at the point of call. How can I tell what package 'main_package_vars' is called invoked from w/o explicitly passing it the package name?

After reading your response, I tried some way of delaying the interpretation of '__PACKAGE__' to interpret it at expansion time, below, but I think I keep ending up with 'two' in main or in the packaged named '__PACKAGE__', which is no help! If you see what I mean...?

I.e., if I was using some package like Class::Accessor, I don't see, yet, how it is getting the current package name and putting the routines into the current package's name space, but this is definitely the direction I'm looking for...maybe I just need to play around with this idea a bit and I'll bump into it...(?)...


In reply to Re^2: Perl templating/macro creating using 'BEGIN'... by perl-diddler
in thread Perl templating/macro creating using 'BEGIN'... by perl-diddler

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.