You say that the above isn't satisfactory for 'singletons'.

Because you're using two screens of fragile and complicated code to replace two lines of code.

To invoke the code, I called a sub 'instance_vars', that was in a begin block.

No, it's not in a BEGIN block. The sub's definition is in a BEGIN block, but I already indicates how that's useless.

Aren't they global variables to each package that are initialized only once

No, they're initialised by the constructor, any number of times.

and then retain their value as global variables in each package (or accessible via package::var) from without the package?

That may be, but you access them via method calls.

I think you are showing me an alternate way of doing what I'm doing, but I don't think it's answering my question

I did. Like I said, you called it too late. You only call class_vars after you try to compile the code that uses them. All I did was made a change to call it earlier.


In reply to Re^3: More Macro work...out to export a definition to next-outer level? by ikegami
in thread More Macro work...out to export a definition to next-outer level? 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.