##
bless $self, $class;
##
##
use Carp qw/confess/;
sub new {
my ($class, @args) = @_;
my $self = bless { name => 'new' }, $class;
$self->loaddata;
return $self;
}
sub loaddata {
my ($self) = @_;
# stuff happens
if ($something_bad_happened) {
confess "Error loading data!";
}
}
##
##
my $obj = coolobject->new or die "$!";
##
##
my $obj = eval { coolobject->new }; # $obj might be undef