package CoolObject; sub new { my $class = shift; my $self = { name => 'new' }, $class; $self->loaddata() or die 'Error loading data'; return $self; #### my $co = CoolObject->new(); # or if you want to trap the error... my $co = eval { CoolObject->new() }; if ($@) { # do something about the error }