#!/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');