Rather than clients keeping a reference to the object, you might use something more akin to the Singleton pattern instead. E.g. something along the lines of Foo->current_instance() that you either use every time you need it or keep in a lexical for (say) the scope of a single sub call.
sub do_bar {
my( $a, $b ) = @_;
my $cur_foo = Foo->current_instance;
##
## Use $cur_foo . . .
##
return $zorch;
}
So each time it's used you'll have the "current" Foo. If you need to change the current instance your private code calls something like Foo->_set_instance( $new_foo ) behind the scenes.
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.