sub myfunction { my $self = get_object( shift ); ... # whatever's function specific, and not related to # creation of the object } sub get_object { my $self = shift; if ( !ref $self ) { return $self->new() } # a string? if ( UNIVERSAL::isa( $self, __PACKAGE__ ) { return $self } return __PACKAGE__->new(); } sub new { ... }