The short answer is, you can't do that. There is no way to share Perl objects between processes. There are things like IPC::Shareable that make it look like you can, but they all do the stuff you mentioned (serialization, locking, etc.) behind the scenes and just move objects around between processes.
There are two pieces of good news though. The first is that there are ways of sharing data that are very fast, like IPC::MM and Cache::Mmap, despite all the machinery. The second is that you probably don't need to do this at all. If you create things before the fork in startup.pl, each child process will get a copy. If you need to share data, you have the above-mentioned methods and your RDBMS. If you need to coordinate access to some shared resource, you can do locking in various ways.
If you explain why you think you need a singleton, we might be able to offer more specific advice about what to do.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.