eval { ... my code here ... # eval is guaranteed to return undef if it fails # this ensures we only enter the do block (return false) # if and only if we die # Note: returns from eval NOT containing sub return 1; } or do { # save $@ because it is fragile and easily reset my $e=$@; ... my error handling code here ... };