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

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Getting all the directories
by hacker (Priest) on Jul 07, 2002 at 14:47 UTC
    You may want to look into using File::Find or File::Basename for your task. They seem to do what you require.

    There's also the SuperSearch for 'directories' found here, which returns quite a bit of other monks with similar questions.

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Getting all the direcotories
by ehdonhon (Curate) on Jul 07, 2002 at 15:39 UTC
    sub finddir { my $root = shift; chomp ( $root ); $root = $root . '/' unless ( $root =~ m|/$| ); local *DIR; opendir ( DIR, $root ); while ( defined(my $file = readdir( DIR )) ) { next unless ( -d $root . $file ); next if ( $file eq '.' ); next if ( $file eq '..' ); print $root . $file, "\n"; finddir( $root . $file ); } }

    Update Fixed two bugs.

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Getting all the direcotories
by stefp (Vicar) on Jul 07, 2002 at 15:03 UTC
    open I, "find $dir -print | "; @ary = map { chomp  } <I>;

    added the -print for sake of portability. Thanks Aristotle for the alternative solution with the "wrapping" chomp. I always forget that one.

    -- stefp -- check out TeXmacs wiki

    A reply falls below the community's threshold of quality. You may see it by logging in.