in reply to Cleaning up a script

As jryan points out, perl closes all open filehandles at the end of the script.

If you want to do some elaborate handling in case of run time errors ( such as die and croak ) you can either:

# use eval eval{ # your code here }; if( $@ ) { # error handling code here } # ... or use $SIG{ __DIE__ } $SIG{ __DIE__ } = sub{ # error handling code here } # your code here

Since $SIG{ __DIE__ } is sort of handled like any other signals, you can specify the value of $SIG{ __DIE__ } just like you specify other signal handlers