package MyPackage; sub new { my $self = $_[0]; bless { foo => $_[1] }, ref($self) || $self; } package main; my $a = MyPackage::->new(1);