package Singleton; use strict; use vars qw($singleton); sub new { $singleton and return $singleton; my $class = shift; my $self = {}; $self->{value} = 0; $singleton = $self; bless $self, $class; } sub getValue { my $self = shift; return $self->{value}; } sub setValue { my $self = shift; $self->{value} = shift; } 1;