1) Just in case you need to do more processing after the unlink in the END block.
That makes sense, but I tend to think that the END{} block should do things as few as possible.
2) So that any caller of the script knows that the script exited with errors (i.e. not retcode 0).
It depends on the programmer whether the failure on unlink is considered an error or not. Unlinking temporary files (specially if originally created by the same process) shouldn't be that serious error. If the same process can't delete them, then it's not the issue of the program. It merely tells that something wrong might happen and it's out of its control to fix it. So, a warning message is sufficient in this case, and the exit code remains 0.
So that the user is notified so maybe he/she can delete the file manually or find out why it couldn't unlink.
The user will get notified with a warning message, and if this is a CGI program, the message goes to the web server error log as well. As to the "why", the reason can be given via $!.
Open source softwares? Share and enjoy. Make profit from them if you can. Yet, share and enjoy!
| [reply] [d/l] [select] |