Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: -e and unlink

by Masem (Monsignor)
on Mar 14, 2001 at 03:36 UTC ( [id://64260]=note: print w/replies, xml ) Need Help??


in reply to -e and unlink

You've basically answered most of your questions: -e does check for existence, and 'unlink' is pretty much the same as doing a unix 'rm <file>'. (Unlink will not remove directories, however). So, to 3), the line checks to see if the file is there, and deletes it if it does.

Why would you use this? Obviously, I'd not use it for data files, but I would use it for lock files which might or might not be created, using such to clean those lock files away at the end of a program. Or, if I was about to write data to a temporary file before moving the temp file in place of another, I'd make sure that tmp file wasn't there before starting. In the case of the DB transactions, maybe the transactions are written to temporary files until the transactions are completed (as such in case of program failure and a COMMIT is not given to the database), and then when COMMIT is given, the changes are now unnecessary, and thus removed. But there's a number of possible reasons why that line is often used in your program, and without further context, it's hard to speculate.


Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-04-18 15:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found