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


In reply to Re: why does open ">..." sometimes touches the directory? by kcott
in thread why does open ">..." sometimes touches the directory? by Mark_Galeck

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.