I am using Net::FTP to write some code that connects to an FTP site scans the directory structure and reports by email on files which have been updated since the last scan. When I do $ftp->dir() I then use a regex which searches for start-of-line followed by either a d or an l in order to separate the directories from the files. This is so I can scan directories and check files. My problem is that files which are symbolic links (lrwxr-xr-x in the dir output) could point to either files or directories. My workaround, which I am not too happy with, is to first assume that they are directories and $ftp->cwd() into the directory checking return codes as I go. When there has been an error I then know that the link was not pointing to a directory but a file so I put it on the file list instead.

Any advice? Am I reinventing the wheel? Are their flaws in my workaround?


In reply to (Dermot) Using Net::FTP, dir(), symlinks: are they files or directories? by Dermot

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.