package Foo; use strict; use warnings; #... my %cache; sub fetch { my $class = shift; my $instance = shift; return $cache{$instance} if $cache{$instance}; my $self = {}; bless ($self, $class); $cache{$instance} = $self; $self->{name} = $instance; # more initialisation. $self; }