On Sun, Jun 12, 2011 at 8:40 PM, eventual <eventualde...@yahoo.com> wrote:
> Thanks,
> I've read perldoc File::Find but I dont understand.
> So If I wish to search for "mp3" in d:\ and all its sub-directories, and to 
> print it out if found,
> How should I write?
> Thanks
>
>
> From: Shawn H Corey <shawnhco...@gmail.com>
> To: beginners@perl.org
> Sent: Saturday, June 11, 2011 11:31 PM
> Subject: Re: using Perl, How to search for files in my computer
>
> On 11-06-11 11:14 AM, eventual wrote:
>> Hi,
>> I am using windows7.
>> Using Perl, how do I search for files in my computer, eg to search in c:\ 
>> and all its sub-directories.
>> I only know how to use glob to search from a particular location.
>> Thanks
>
> You can use File::Find, see `perldoc File::Find`.  It is a standard module 
> and is installed along with Perl.  For a list of all the standards pragmatics 
> and modules, see `perldoc perlmodlib`.
>
>
> -- 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.
>
> -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/

I am only learning myself. But from the docs this is the format we
should follow.

use File::Find;
    finddepth(\&wanted, @directories_to_search);
    sub wanted { ... }

So then I didn't fully understand the docs either, but found this at
perlmonks http://www.perlmonks.org/?node_id=217166 and the File::List
here at CPAN http://search.cpan.org/~dopacki/File-List-0.3.1/List/List.pm

My Stab at it


use File::List;

my $mp3 = new File::List("C:\MyMusic\");
my @musicFiles = @{ $mp3->find("\.mp3\$") };
@musicFiles = sort(@musicFiles);
foreach (@musicFiles)
{
          print " $_ ";
}

Well something like that.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to