$@=undef; { local $@; ... } # $@ is undef here, no matter what "..." is.