use MyModules::Config; # here's the singleton magic: # "new" recalls the existing instance if any. my $conf=Config->new(); #### package Config; # this is the package variable to store # the used instance my $single; # modules use Carp; sub new { # usual stuff here... my $proto = shift; # create a new object if no instance currently active unless ($single) { $single = {} ; # where to store data $single->{options} = {}; } bless($single); return $single; } # here is the method to parse the conf. file # and load the data in the Config object sub parseconffile { my $config = shift; # here put something useful... } # end 1;