Please don't spread misinformation.

I wasn't.

Well, actually, it does (or if you wanna be anal, it depends).

Right. It depends. In other words, unlink() does not delete files; it does something else which might result in files being deleted. I really don't care what perldoc -f unlink says because, in this case the docs are not, as you put it, "anal." Their imprecision is forgivable because it is a messy topic with multiple exceptions depending on operating system and filesystem features.

On Unix, Perl's native platform, unlinking generally removes a directory entry, or "link". Hence the name of the function. Although many files have only a single directory entry, that's not at all guaranteed. In that case, if you call unlink() and pass just one of the file's directory entries, the file itself will not be removed even if unlink() successfully removes the link and returns 1.

Also, on Unix, unlinking an open file works just fine. I've even seen it used on purpose. Nevermind what perlport says; not everyone cares about writing portable Perl.

Versioned filesystems, as you yourself point out, are another example of how unlink() may not delete a file. There is a variable, UNLINK_ALL_VERSIONS, however, which can be defined at compile time to make perl on VMS behave similarly to perl on Unix.

Some operating systems don't have links at all.

And, on those crippled platforms, the overly simplistic explanation given in perldoc -f unlink is sufficient.

-sauoq
"My two cents aren't worth a dime.";

In reply to Re: Re: Re: Re: unlink Question by sauoq
in thread unlink Question by lisaw

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.