Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
G'day most revered brethren ,

My reading of the file test operators perldoc (perl v5.14.2 on 32 bit Linux) suggests that the -f test will return true iff the file being tested is a regular file. However, when recently putting this to the test, I observed unexpected behaviour when run against a sym link - the following code is a simple demo of, what I consider to be, the problemmatic behaviour ...

$ file file file: empty $ file link link: symbolic link to `file' $ $ perl -e 'printf "%d%d%d%d\n", -f "file", -f "link", -l "file", -l "l +ink"' 1101
As you see, -f returns a true value for the sym link which, IMO, is most definitely not a regular file; So the question is: is it my reading of perldoc or is it actually errant behaviour ?

I thank you in advance in anticipation of your consideration of the above.

UPDATE: As was suggested by choroba, it seems, on AIX, Solaris & Linux at least, as though symlinks are indeed followed .. and the same holds true for the -f and -d operators in the shell ... which begs the question: what on earth is the point of the -follow option to the find(1) command ?

A user level that continues to overstate my experience :-))

In reply to Should -f test return true for symlinks ? [RESOLVED] by Bloodnok

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others musing on the Monastery: (8)
    As of 2020-10-27 15:37 GMT
    Find Nodes?
      Voting Booth?
      My favourite web site is:

      Results (257 votes). Check out past polls.