I write scripts that need to report exit status to the applications that call them.
I found that when I call die from inside a subroutine, the return code is always 0. Even playing with $! doesn't have any effect.
die called outside any subroutine has the right behaviour and ends the program with a non 0 return code (or can be forced by using the $! variable).
Tested on Unix and Windows and ActiveState Perl 5.8.8.
You can check this with:
perl -e 'die'; echo $?
perl -e 'sub {die}': echo $?
Is this a bug or I'm doing something wrong?