use File::Find::Rule; my @mp3_files = File::Find::Rule->file->name(qr/ \. mp3$ /x)->in("C:/");
Tada. The problem with this (and all previous) solutions is that, if you have filenames with non-English (bah, ascii/latin-1) characters, you'll get a bunch of garbage instead. I'm not aware if there's a portable solution for this at the moment - For windows, see [0]; For Linux (or well, Ubuntu at least), some variation of this will probably make do (untested, but should work): use feature 'unicode_strings'; use Encode (); use List::MoreUtils qw( any ); ... # mp3 filename getting code of your choice if ( any { /\P{ASCII}/ } @mp3_files ) { @mp3_files = map { Encode::decode( "UTF-8", $_ ) } @mp3_files; } Handling Unicode is hard word[1] :( Brian. [0] http://www.i-programmer.info/programming/other-languages/1973-unicode-issues-in-perl.html [1] http://stackoverflow.com/questions/6162484/why-does-modern-perl-avoid-utf-8-by-default