Re: List of directories within a directory



"AM" == Al Moodie <nospam@xxxxxxxxxx> writes:

AM> On Wed, 30 Jan 2008 02:30:16 GMT, "John W. Krahn"
AM> <someone@xxxxxxxxxxx> wrote:

>> Al Moodie wrote:
>>> I have a directory with 200 sub directories in it. How do I create a
>>> list of the sub directory names?

>>>
>>> but how do I do it for the directories within a directory
>>
>> my @dir_names = grep -d "$dirname/$_", readdir DIR;

AM> That is what I need. I want to go into each sub directory in turn and
AM> delete specific files.

then you should use File::Find or one of the variants. scanning dirs
deeply by yourself has all sorts of little bugs waiting to happen.

uri

--
Uri Guttman ------ uri@xxxxxxxxxxxxxxx -------- http://www.sysarch.com --
----- Perl Architecture, Development, Training, Support, Code Review ------
----------- Search or Offer Perl Jobs ----- http://jobs.perl.org ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
.



Relevant Pages

  • Re: List of directories within a directory
    ... Al Moodie wrote: ... list of the sub directory names? ... Didn't I just read exactly the same question from a name sake of yours in a ...
    (comp.lang.perl.misc)
  • Re: List of directories with a directory
    ... Al Moodie wrote: ... list of the sub directory names? ... I would simply use File::Find and prune the search tree ata depth of 2. ...
    (comp.lang.perl)
  • Re: List of directories within a directory
    ... list of the sub directory names? ... Didn't I just read exactly the same question from a name sake of yours in a ... second post here. ... Al Moodie. ...
    (comp.lang.perl.misc)