Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Tmpnam and END blocks

by archfool (Monk)
on Jul 05, 2007 at 14:51 UTC ( [id://625054]=note: print w/replies, xml ) Need Help??


in reply to Tmpnam and END blocks

I think the die's purpose is threefold:
1) Just in case you need to do more processing after the unlink in the END block.
2) So that any caller of the script knows that the script exited with errors (i.e. not retcode 0).
3) So that the user is notified so maybe he/she can delete the file manually or find out why it couldn't unlink.

Replies are listed 'Best First'.
Re^2: Tmpnam and END blocks
by naikonta (Curate) on Jul 05, 2007 at 22:43 UTC
    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!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://625054]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-18 05:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found