in reply to Re: Re: Re: unlink Question
in thread unlink Question

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.";