in reply to Re^2: Design of a global-variable storage package (string)
in thread Design of a global-variable storage package
I thought of that $p part, too, just forgot to mention it. I'm not sure, though, that this would be better-received. ;-)
As for your non-singleton approach - something like this?
And, perhaps, a way to change the global instance to be another one, if you really do need More Than One?my $default; sub new { my $class = shift || __PACKAGE__; my $self = {}; bless $self, $class; $default ||= $self; } sub global_instance { $default ||= (shift || __PACKAGE__)->new(); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Design of a global-variable storage package (Two)
by tye (Sage) on Nov 23, 2005 at 21:11 UTC |