in reply to Return an Array of Sub-Dir Names

Far too much work.
use File::Find; sub get_sub_dirs { my @return; find sub { push @return, $File::Find::name if -d; }, @_; @return; }

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: Re: Return an Array of Sub-Dir Names
by AltBlue (Chaplain) on Sep 26, 2001 at 00:46 UTC
    File::Find will get us an entire directory tree ;-) ... so you should insert some 'prune' there :)

    ...wouldn't globing be good enough for this simple job? =)

    sub subdirs { my $dir = shift; my @subd = (); for(<$dir/*>) { next unless -d; s".+/""; # lame 'basename' surogat :) push @subd, $_; } @subd; }
    .. IAE, it is indeed too much work for this ;)

    --
    AltBlue.