Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Reading from a deleted file is futile

by dynamo (Chaplain)
on Feb 12, 2008 at 12:52 UTC ( [id://667552]=note: print w/replies, xml ) Need Help??


in reply to Reading from a deleted file is futile

To determine whether a file is deleted or not (i.e., as jrtayloriv pointed out, whether there is an entry for it in it's directory), I feel compelled to offer yet another possible solution.

When I want to know if a file has been deleted or not (in a unix-like system,) I run ls, to list the directory's contents. If the entry has been removed, the file should be missing.. so this is one option (somewhat simplified):

$filename = "openfile.yaml"; $directory = "/over/here/somewhere/i/think/"; $fileIsDeleted = (`ls $directory` !~ /$filename/gs); print "Your file has ".($fileIsDeleted ? "" : "not ")."been deleted.";
This code has not been tested, but looks ok to me. It's really about the idea behind it anyway.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2024-04-18 11:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found