That's good defensive programming
It sure is!
Defensive programming can bite you, though. Kane, one of the Rotterdam Perl Mongers once told the story about what happens if you localize $@ in a BEGIN block. By programming defensively, he ran into a bug in perl :)
perl -e'BEGIN { local $@; print "a"; die "b"; print "c"; } print "d";'
It turns out that the program doesn't die, and it doesn't display "b" (and not "at -e line 1"). The snippet above prints "ad". If it didn't localize $@, it would print:
b at -e line 1.
BEGIN failed--compilation aborted at -e line 1.
Scary, huh?
If you localize special variables, look out for bugs, and if you find any, report them!
U28geW91IGNhbiBhbGwgcm90MTMgY
W5kIHBhY2soKS4gQnV0IGRvIHlvdS
ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
geW91IHNlZSBpdD8gIC0tIEp1ZXJk