Chas. Owens wrote: > On Mon, May 18, 2009 at 19:41, AndrewMcHorney <andrewmchor...@cox.net> wrote: >> Charles >> >> I am getting totally confused. All I want is a simple find function call >> what will return all the files that are in c:\*.*. This is on PC running >> windows. I thought you mentioned to use file:find() where one of the >> parameters would be a function which would be called once for each file >> found. > snip > > After these two lines run @files will hold every file on the c drive. > > my @files; > find sub { push @files, $File::Find::name if -f }, "c:/"; > > > -- I like and often recommend using File::Find. However, in this case, I think it would be better to use backticks or qx() to call the Windows dir command.
Here's a benchmark script and it's results on my system. #!/usr/bin/perl use strict; use warnings; use File::Find; use Benchmark qw/cmpthese/; cmpthese( 10, { 'dir' => sub {my @files = `dir /b /a-d /s c:\test` }, 'filefind' => sub {my @files; find sub {push @files, $File::Find::name if -f }, "c:/test"}}, ); --- C:\test>test.pl s/iter filefind dir filefind 1.67 -- -93% dir 0.119 1304% -- -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/