package MyIsolatedFunction; my $singleton = undef; sub new { my( $class ) = @_; return $singleton if defined $singleton; my $self = 0; $singleton = bless \$self, $class; return $singleton; } sub isolatedFunction { ... # Normal function stuff here. } 1;