in reply to Sharing objects between modules

sorry, i don't have alot of experience with packages and namespaces in perl so i could be way off or just offering bad advice, but couldn't you just declare whatever you want to share as a package-level variable and then access it by its full-qualified name in other modules?
#!perl -l use strict; use warnings; package Pizza; $Pizza::foo = "bar"; package Pizza::Milkshake; print $Pizza::foo;
any enlightment on whether or not this The Wrong Way(tm) are welcome.

perl -e"\$_=qq/nwdd\x7F^n\x7Flm{{llql0}qs\x14/;s/./chr(ord$&^30)/ge;print"

Replies are listed 'Best First'.
Re: Re: Sharing objects between modules
by chromatic (Archbishop) on May 05, 2004 at 04:54 UTC

    That's perfectly fine in many cases; it's as much a singleton as anything else.

    One potential drawback is that it's possible to overwrite a global variable, though. If you use some sort of closure to store the singleton, you'll have less chance of overwriting the variable accidentally.