in reply to My brain hurts! Recursive directory algorithm..
That should help you structure your problem....use File::Find; use File::stat; our @current_bucket; our $current_size = 0; our $BUCKET_SIZE = 4000000000; sub add_to_bucket { my $size = stat($_)->size(); if ($size + $current_size > $BUCKET_SIZE) { # reset bucket process_bucket(\@current_bucket); @current_bucket = (); $current_size = 0; } $current_size += $size; push @current_bucket, $File::Find::name; } sub process_bucket { my $bucket = shift; # here do things like compress the list to contain # parent directories, etc, if you really need to do this # then print out the list. } find(\&add_to_bucket, "/data");
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: My brain hurts! Recursive directory algorithm..
by waswas-fng (Curate) on Jul 25, 2002 at 19:36 UTC |