Well, there are a couple ways to do it. Here are three:

Out of these three, I would definitely recommend File::Find. There is the least chance of something going horribly, horribly wrong. :-) You should read the File::Find manpage, but since you are a self-proclaimed newbie, I'll give you an example!

#!/usr/bin/perl # enable strict syntax checking and warnings # you should (pretty much) always use these use strict; use warnings 'all'; # include our friendly neighborhood file finder use File::Find; sub list_mp3 { # our regex to check for the .mp3 extension /.*?\.mp3$/ && do { # but we're not done yet! # this `do' block will perform any voodoo and output # you want on files that match the above regex # here's a real simple output: print $File::Find::name, "\n"; # See the File::Find manpage for the different variables to use. # You can obviously dress the output up a lot more than this. } # end the do-block } # end the subroutine # finddepth() is a function from File::Find # we have to tell it A) what function to use, and # B) where to start searching # # this will start at /hd/mp3 and search downward, passing # each file to the list_mp3 function above finddepth(\&list_mp3, '/HD/MP3');

If you need me to clarify anything, just holler. Hopefully this will be enough to get you started!

Alakaboo


In reply to RE: Easier way to do this by mwp
in thread Easier way to do this by LoneRanger

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.