Localizing $@ would have protected your caller against your clobbering $@. You'd still have the alias/copy bug so now shift() would always return undef because $@ now is always blank but at least you'd be safer. When using $@, always, always, always copy it out first. The smallest piece of code can go clobber $@ so you should always copy it out before examining it.
sub foo { local $@; return eval { bar( shift ) } || 0; }
⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊
In reply to Re^2: Spot the bug!
by diotalevi
in thread Spot the bug!
by tlm
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |