http://www.perlmonks.org?node_id=280704


in reply to Creating 'universal' instances of objects?

Sounds to me that Class::Singleton is exactly what you are after.

Deriving from that class will ensure that only one instance of your class will be returned:

package Grok; use vars qw(@ISA); @ISA = qw(Class::Singleton); package Main; my $one = Grok->instance(); # returns a new instance my $two = Grok->instance(); # returns same instance
Hope this helps.