package Foo; sub new { print "Foo\n"; bless {} } package Bar; sub new { print "Bar\n"; bless {} } sub addFoo { my $self = shift; $self->{Foo} = new Foo(); # which new gets invoked? } package main; my $bar = new Bar(); $bar->addFoo(); # if there's a bug, this should tickle it