in reply to Multiple Inheritance - Howto marry tie::refhash::nestable with class::singleton
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Multiple Inheritance - Howto marry tie::refhash::nestable with class::singleton
by hoppfrosch (Scribe) on May 31, 2005 at 13:14 UTC | |
by merlyn (Sage) on May 31, 2005 at 13:43 UTC | |
by hoppfrosch (Scribe) on May 31, 2005 at 14:12 UTC | |
by dragonchild (Archbishop) on May 31, 2005 at 13:26 UTC |