http://qs321.pair.com?node_id=561895

Rethrowing an exception with die $@ if (some expression involving $@) (an idiom mentioned at least 6 times in the perl documentation) has a problem when the expression involving $@ ends up doing anything that inadvertently clears $@. Consider:
use overload q!""!=>sub{ eval { "whoops" } }; eval { die bless {} }; die $@ if $@;
Here, we die with an exception object that should stringify to "whoops", but $@ ends up being cleared before the rethrow. (To highlight the maybe-expected vs. observed results, change eval { "whoops" } to just "whoops" or remove the if $@.) The better way to do it would be
use overload q!""!=>sub{ eval { "whoops" } }; eval { die bless {} }; my $exception = $@; die $exception if $exception;