Ah, but the best way to learn (IMO) is to copy and tweak. Yes, it spawns a lot of cargo-cult, but not everyone has the time, the effort and the inclination to devour every word of a man page, especially poorly written ones! So, let's work at tweaking this one:
sub wanted { -l && !-e && print "bogus link: $File::Find::name\n"; }

perldoc perlfunc will show you a list of all the file test functions available. -l means 'is a symlink' and -e means 'file exists'. What File::Find does is apply the 'wanted' sub (or any other sub-ref passed) to every file it finds (with $_ locally set as the filename, having chdir-ed to any directory it finds), so in this case it checks first of all if the file is a symlink (-l), and then if the file doesn't actually exist (-e). If this is true then it tells you that that link is broken (using $File::Find::name which is the fully qualified file name, relative to where you are) So, say we actually wanted to find all .mp3 files. We'd use something like:

sub wanted { return unless -f && /\.mp3$/; print $File::Find::name, "\n"; }

Or, you could push them to an array, or whatever. Then you just call this as: find (\&wanted, $BASEDIR)

Tony


In reply to Re: Re: Re: Re: Re: Re: file (mp3) list shown on website as links by salvadors
in thread file (mp3) list shown on website as links by Nimster

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.