On 10/7/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Good Afternoon > > I am attempting to develop a script that will parse a directory listing and > return only directory names that match a given expression. > > It would make sense to me to use File::Find to do this but based on the dir > structure I am parsing, the amount of overhead to do this is enourmous ! > > Basically, I have a file structure similar to: > > Dir1\Dir2\Support\119404\dirx\diry > Dir1\Dir3\Support\119893\dirx > Dir1\Dir4\Support\188884\dirx\diry\dirz > ..... > Dir1\Dir1000\Support\100858 > > I am simply interested in finding the directories directley under the Support > dir (ex.119404 from the 1st example) . There is no consistancy to the naming > convention other then Dir1 and Support. Dir2 can be many different values. > > I tried functionality similar to the following that did work on a much > smaller test bed: > > my $dirs="I:\\ID_000000_000999"; > find sub { push @dirs, $File::Find::dir if $File::Find::dir =~ > m/.+[Ss]upport\/\d+$/;}, $dirs;
This is not only processing directories, but any files present as well. It will probably be a considerable (although untested) speedup to do something like: my $dir="I:\\ID_000000_000999"; our @dirs; sub callback { push @dirs, $_ if /.+[Ss]upport\/\d+$/; } sub filter { # we only care about directories return grep(-d $_, @_); } find { wanted=>\&callback, preprocess=>\&filter, no_chdir=>1 }, $dir; print @dirs; Read up on File::Find, and consider putting some prints in your callbacks to see what's getting called and exactly what it's doing. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>