in reply to Where did $@ go?

an empty string for $@ that tests as true

The last time I saw such weirdness (empty string tests as true), my so called empty string contained a null character as its first character. To confirm this print out $@ with Devel::Peek::Dump (see Devel::Peek).

As for how that null got there? Anybody's guess. Exiting an eval block triggers the destructors for all data that is no longer needed. If there is an eval in one of those destructors, $@ can be easily reset. I didn't see any DESTROY subroutine in either Mail::Builder::Simple or Mail::Builder. However, Mail::Builder uses Moose which has plenty of magic and there are several other modules involved as well. Any one of them could be doing something that causes $@ to be reset.

My own preferred syntax for exception handling is

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 ... };