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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|