Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: why does open ">..." sometimes touches the directory?

by kcott (Abbot)
on Feb 05, 2013 at 09:29 UTC ( #1017090=note: print w/ replies, xml ) Need Help??


in reply to why does open ">..." sometimes touches the directory?

G'day Mark,

The directory is a file. You can view it in an editor. When you open a file for writing, even if you don't write anything, the information in the directory file will change and, accordingly, so will the timestamp. You can see this for yourself at the command line (i.e. without using perl) - here's a sample run:

ken@ganymede: ~/tmp $ ls -al check_dir_touch ls: check_dir_touch: No such file or directory ken@ganymede: ~/tmp $ mkdir check_dir_touch ken@ganymede: ~/tmp $ ls -al check_dir_touch total 0 drwxr-xr-x 2 ken staff 68 5 Feb 20:12 . drwxr-xr-x 211 ken staff 7174 5 Feb 20:12 .. ken@ganymede: ~/tmp $ view check_dir_touch --------------------- Editor window shows various info with no files listed (exit editor without attempting to save anything) --------------------- ken@ganymede: ~/tmp $ > check_dir_touch/fred ken@ganymede: ~/tmp $ ls -al check_dir_touch total 0 drwxr-xr-x 3 ken staff 102 5 Feb 20:19 . drwxr-xr-x 210 ken staff 7140 5 Feb 20:18 .. -rw-r--r-- 1 ken staff 0 5 Feb 20:19 fred ken@ganymede: ~/tmp $ view check_dir_touch --------------------- Editor window now shows "fred" (exit editor without attempting to save anything) ---------------------

I agree with vinoth.ree's comment about using the 3-argument form of open; however, that won't change the behaviour of the underlying operating system.

-- Ken


Comment on Re: why does open ">..." sometimes touches the directory?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2014-12-19 23:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (94 votes), past polls