in reply to Re: single instance shared with module
in thread single instance shared with module

A singleton is even easier to do in Perl. You don't even need a reference. Because in Perl you can say
my $class = "Singleton"; $class->method();
you only need to return a string with the package name in a singleton's constructor.
package Singleton; my ($various, %instance, @variables); sub new { my $class = shift; # object initialization here ... *new = sub { shift } return $class; } 1;

Here we also avoid the need to check whether the object is initialized by using a glob to replace &new. None of the further calls to the constructor will execute its initial code.

All of your methods can just ignore the $self too, since there's a single instance which stores its data in file lexicals.

Makeshifts last the longest.