A bit more on this.

Files exists independently of directory entries in unix. Think of them as being referenced-counted. They exist as long as they are referenced by a directory entry or by a file handle.

This means you can have "anonymous files". perl -i uses this (which is why it doesn't work on Windows without an extension). File::Temp creates these by default.

ls -l even shows how many times a file is referenced by a directory entry (second column). For plain files, it's usually one. For directories, it should be more than one.

$ ls -ld . .. .bash* bin usr drwxr-xr-x 10 ikegami ikegami 4096 Feb 19 23:53 ./ drwxr-xr-x 3 root root 4096 Dec 10 21:14 ../ -rw------- 1 ikegami ikegami 163 Jan 3 02:07 .bash_logout -rw------- 1 ikegami ikegami 2318 Jan 3 02:07 .bashrc -rw------- 1 ikegami ikegami 0 Jan 3 02:07 .bashrc_extra drwx------ 2 ikegami ikegami 4096 Feb 14 12:13 bin/ drwx------ 3 ikegami ikegami 4096 Jan 24 15:39 usr/

See how .. is referenced by three directory entries? Those are /home, /home/. and /home/ikegami/..

See how . is referenced by ten directory entries? Those are /home/ikegami, /home/ikegami/., /home/ikegami/bin/.., /home/ikegami/usr/.., etc.


In reply to Re^5: Bad file descriptor when trying to close file handle by ikegami
in thread Bad file descriptor when trying to close file handle by fireblood

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.