#!/usr/bin/perl -w use strict; package foo; { my $self = { foo => bar }; sub new { return bless $self, shift; } sub get_obj { return UNIVERSAL::isa($self, 'foo') # or not as cool: #return ref($self) eq 'foo' ? $self : goto &new; } }