<?xml version="1.0" encoding="windows-1252"?>
<node id="788917" title="Answer: How do I find directories within directories using : parse_dir(`ls -l`)" created="2009-08-15 14:14:51" updated="2009-08-15 14:14:51">
<type id="1888">
categorized answer</type>
<author id="11732">
QandAEditors</author>
<data>
<field name="doctext">
If you could use some other module, [mod://File::Slurp] provides a &lt;c&gt;read_dir&lt;/c&gt; function which can be used as follows.
&lt;p&gt;
&lt;c&gt;read_dir&lt;/c&gt; returns a list of directory contents.
&lt;p&gt;
[doc://grep] [doc://-X|-d] selects only directories (filtering out files).
&lt;p&gt;

&lt;c&gt;
use File::Slurp;

my @dirs = grep { -d "$dir/$_" } read_dir($dir);
&lt;/c&gt;

&lt;p&gt;To include the . and .. special directories, add the &lt;c&gt;keep_dot_dot&lt;/c&gt; option:
&lt;c&gt;
my @dirs = grep { -d "$dir/$_" } read_dir($dir, keep_dot_dot=&gt;1);
&lt;/c&gt;</field>
<field name="parent_node">
109269</field>
</data>
</node>
