I've had some confusion about singleton objects and "scope"- of that object "instance".

I've seen stated that you can have only one instance of a singleton object- system wide. This is complete bs- right? A gross blanket statement.

It seems a singleton object is only good for the - how would you say this.. process? application instance? whatever first set your program in motion via the perl interpreter? The opening line here seems much more sensible.

If a singleton object were good system wide, it would mean that simply by calling use X, every process started by every user/non-user on that system shares the same access to the same data, (perhaps in memory in this case? or swap.. who knows). As I experience it- a singleton is not a one line daemon-ish hack.

I imagine the way to do this really- would be store the object instance in ram- even caching wouldn't do here- the technicalities are way beyond me.

So- could we get some clarification as to what a singleton really does as far as scope- where with an object, each is it's own thing- a singleton is the same thing as far as the current instance of your initial process/app instance is concerned, is this correct?


In reply to what is the real scope of a singleton by leocharre

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.