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 :)
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:perl -e'BEGIN { local $@; print "a"; die "b"; print "c"; } print "d";'
Scary, huh?b at -e line 1. BEGIN failed--compilation aborted at -e line 1.
If you localize special variables, look out for bugs, and if you find any, report them!
U28geW91IGNhbiBhbGwgcm90MTMgY
W5kIHBhY2soKS4gQnV0IGRvIHlvdS
ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
geW91IHNlZSBpdD8gIC0tIEp1ZXJk
In reply to Re: Re: Devious destructor
by Juerd
in thread Devious destructor
by bluto
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |