Sayth Renshaw wrote:
Try:
my @Music_files = ();
use File::Find;
find( \&want_mp3, 'd:\\' );
print "$_\n" for sort @Music_files;
sub want_mp3 {
push @Music_files, $File::Find::name if $_ =~ /\.mp3$/;
}
--
Just my 0.00000002 million dollars worth,
Shawn
Confusion is the first step of understanding.
Programming is as much about organization and communication
as it is about coding.
The secret to great software: Fail early& often.
Eliminate software piracy: use only FLOSS.
That was good to see Shawn. I kept working on it but mine was far more
convoluted, and didn't like spaces in directory names.
#!\usr\bin\perl
use warnings;
use strict;
use diagnostics;
use File::List;
use File::Find;
my $mp3;
my @musicFiles;
my $dirList;
my $dir = ("c:/");
my @dirList = find(sub {print if -d}, $dir);
# old file line $mp3 = new
File::List("C:/Users/RenshawFamily/maven/Music/Foo Fighters");
foreach $dirList (@dirList) {
@musicFiles = @{ $dirList->find("\.mp3\$") };
}
@musicFiles = sort(@musicFiles);
foreach (@musicFiles)
{
print " $_ ", "\n";
}
Sayth
Hi Sayth, et. al.,
At work I'm stuck on Winblows, and this is one of the ways Strawberry
Perl (portable install) saves me lots of time. There's nothing wrong
with the other solutions presented; I'm just adding to the variety... I
use these one-liners if I need a quick search while playing in DOS
(doesn't sort, just prints as it gets 'em):
perl -MFile::Find -wle "find( sub{ /\.mp3$/i and print;}, q(.));"
perl -MFile::Find -wle "find( sub{ /\.mp3$/i and print
$File::Find::name;}, q(.));"
The first I tend to use when I just want an "existence check" and I
don't need the directory info.
\Brian
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/