ewittry has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to find all subdirectories between a min and max depth.

Note: I am testing this on Linux, but also need it to run on windows.

use strict; use File::Find::Rule; my $directory ="/vol/engtemp/IMFT-RND/FAB4_YE/www/es/"; my @subdirs = File::Find::Rule->mindepth(1)->maxdepth(9)->directory->i +n( $directory ); foreach my $subdir (@subdirs){ print "$subdir\n"; }

ummm.. I think I figured it out. Never fails when you ask somebody for help, a light bulb goes off. If I take the last "/" off of my $directory string, then it works... Now can some one explain why it didnt work with the "/" at the end?

Replies are listed 'Best First'.
Re: Help on File::Find::Rule Please
by ww (Archbishop) on Jan 12, 2012 at 14:49 UTC
    Runs fine, as is, on win32 (w2k used for test).

    would be more useful, I suspect, if it took (at least) the searchdir ($directory) and (somewhat more work) the depths from the command line.

    But is either of those the answer to the question you didn't ask?

    UPDATE Your update "ummm.. I think I figured ... the "/" at the end?" -- which appeared after two replies -- is noted and merely inspires the same reply as toolic provided: HOW didn't it work?

    And please, when you update, annotate the node (as done here) so as to leave any extant replies with some context.

Re: Help on File::Find::Rule Please
by toolic (Bishop) on Jan 12, 2012 at 14:36 UTC
    it didnt work
    In what way did it not work?

    It gives me identical output (on linux) with or without a trailing /.