{ package Foo; sub new { my ($class, $id) = @_; my $self = { id => $id }; my ($package) = caller; ${$callpkg."::".$id} = bless $self, $class; undef; } sub method { my ($self, $name) = @_; print $self->{id}, "\n"; } } Foo->new('one'); Foo->new('second'); $one->method; $second->method;