You should probably test on a smaller data set then? Anyway, I'm getting different results, my original code being roughly 55% faster on my single user machine (as expected).

I added a native Perl implementation that walks the tree itself with no overhead and that gains you another significant speed boost.
D:\ENV>perl pm10.pl Holli (New). Found: 1 ( D:\env\Videos/2012 ) Time: -19 Holli (original). Found: 1 ( d:\env/Videos/2012 ) Time: -32 ovedpo15. Found: 1 ( d:/env/Videos/2012 ) Time: -51
Using this code.
use File::Find; use File::Spec::Functions; use Cwd qw(abs_path); sub holli2 { my @found; my $path = 'd:\env'; my $target = "2012.avi"; myfind( \@found, $path, $target ); print "Holli (New). Found: ", scalar @found, " ( @found )", "\n"; } sub myfind { my ($found, $path, $target ) = @_; if ( opendir( my $in, $path ) ) { while ( my $dir = readdir($in) ) { next if $dir =~ /^\.\.?$/; my $entry = "$path/$dir"; if ( -d $entry ) { myfind( $found, $entry, $target ) } else { push @$found, $path if ($dir eq $target) && (!-e "$path/.ignore"); } } closedir($in); } else { print qq(Skipping "$path": $!\n); return; } } sub holli { my @found; my $path = 'd:\env'; my $target = "2012.avi"; find ( sub { # We're only interested in directories return unless -d $_; # Bail if there is an .ignore in the current directory return if -e "$_/.ignore"; # Add to the results if the target is found here push @found, $File::Find::name if -e "$_/$target"; }, $path); print "Holli (original). Found: ", scalar @found, " ( @found )", " +\n"; } sub ovedpo15 { my @found; find( sub { get_dirs( \@found, $_ ) }, 'd:\env'); print "ovedpo15. Found: ", scalar @found, " ( @found )", "\n"; } sub get_dirs { my ($dirs_aref, $current_path) = @_; $triesOvedpo15++; eval { my $abs_path = abs_path($current_path); my $file = $abs_path."/2012.avi"; my $ignore_file = $abs_path."/".".ignore"; push (@{$dirs_aref},$abs_path) if((-e $file) && !(-e $ignore_f +ile)); }; } my $t = time(); holli2(); print "Time: ", ($t - time), "\n"; $t = time(); holli(); print "Time: ", ($t - time), "\n"; $t = time(); ovedpo15(); print "Time: ", ($t - time), "\n";


holli

You can lead your users to water, but alas, you cannot drown them.

In reply to Re^5: Finding files recursively by holli
in thread Finding files recursively by ovedpo15

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.