Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: The situational efficiency of File::Find

by OzzyOsbourne (Chaplain)
on May 09, 2001 at 19:45 UTC ( #79125=note: print w/replies, xml ) Need Help??


in reply to The situational efficiency of File::Find

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://79125]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (2)
As of 2022-10-02 06:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (7 votes). Check out past polls.

    Notices?