Update: File::Find even with the prune option seems to take way more time than this piece of code. I say "seems", b/c I canned the file::find version once it ran over the time of this code's benchmark.

Thanks (++) for all the help!

# Finds all of the thingtolookfor.txt across all servers and prints ou +t a list # of those people that do not have them to log.txt use strict; use Benchmark; my $t0 = new Benchmark; my ($server,$usershare); my $out='//mymachine/myshare/log.txt'; my @servers=('XXY','ZZZ','ETC'); open OUT,">$out"; foreach $server (@servers){ my $dir1="//$server/c\$/chompy"; # Check if chompy share is on $C or D$ if (!(-e "$dir1")){#if directory doesn't exist try d$ $dir1="//$server/d\$/chompy"; if (!(-e "$dir1")){ die "Directory not does not exist on $server\n...Exiting S +cript.\n"; } } # Read the user shares opendir(DIR, $dir1) or die "can't opendir $dir1: $!"; #weed out dots and get only dirs my @dirs = grep { !/^\./ && -d "$dir1/$_" } readdir(DIR); closedir DIR; foreach $usershare(@dirs){ my $userdir="$dir1/$usershare"; if (!-e "$userdir/thingtolookfor.txt"){ print OUT "$userdir:\tno\n"; print "$userdir:\tno\n"; } } } close OUT; #benchmarking info my $t1 = new Benchmark; my $td = timediff($t1, $t0); print OUT "The code took:",timestr($td),"\n";

-OzzyOsbourne


In reply to Re: The situational efficiency of File::Find by OzzyOsbourne
in thread The situational efficiency of File::Find by OzzyOsbourne

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.