eval{ my $obj = $facory->get_instance('thingy'); $obj->run(); $obj->closedown(); }; if($@) { print $@; }