Hello hatz,
I'm not sure what would happen if my program exits before my close() command because of other reasons such as another file that cannot be opened (the famous "open $bar or die")
Put the close command in an END { ... } block. Code in END blocks runs when the program terminates, even if the termination is caused by an uncaught exception or an exit command:
12:55 >perl -wE "END { say 'Bye!' } say 'Hi!'; die 'D\'oh!';" Hi! D'oh! at -e line 1. Bye! 12:55 >perl -wE "END { say 'Bye!' } say 'Hi!'; exit 0;" Hi! Bye! 12:55 >
See perlmod#BEGIN, UNITCHECK, CHECK, INIT and END.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re: die command while other files are opened
by Athanasius
in thread die command while other files are opened
by hatz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |