Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://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

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-03-29 12:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found