Please read ref($proto) - just say no!.my $class = ref($proto) || $proto;
Now, it looks like you're enamored with shiny objects. Let's get back to the basics. You want a hash that is in every namespace? Then simply create a module that populates the hash and exports it:
And to use it:package MyGlobalHash; use base Exporter; @EXPORT = qw(%MyGlobalHash); %MyGlobalHash = (foo => "Hello, world!\n"); 1;
There. No singleton or tie or any of that junk needed. If that won't suffice, please clarify.package RandomPackage; use MyGlobalHash; ... print $MyGlobalHash{"foo"};
Also keep in mind that I hate global data. You should export behavior, not data. You should avoid global data as much as possible, because it creates nasty couplings that keep you from refactoring or reusing or testing code well.
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
In reply to Re: Multiple Inheritance - Howto marry tie::refhash::nestable with class::singleton
by merlyn
in thread Multiple Inheritance - Howto marry tie::refhash::nestable with class::singleton
by hoppfrosch
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |