Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Answer: How do I find directories within directories using : parse_dir(`ls -l`)

( #788917=categorized answer: print w/ replies, xml ) Need Help??

Q&A > directories > How do I find directories within directories using : parse_dir(`ls -l`) contributed by toolic

If you could use some other module, File::Slurp provides a read_dir function which can be used as follows.

read_dir returns a list of directory contents.

grep -d selects only directories (filtering out files).

use File::Slurp; my @dirs = grep { -d "$dir/$_" } read_dir($dir);

To include the . and .. special directories, add the keep_dot_dot option:

my @dirs = grep { -d "$dir/$_" } read_dir($dir, keep_dot_dot=>1);

Comment on Answer: How do I find directories within directories using : parse_dir(`ls -l`)
Select or Download Code
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (10)
As of 2014-11-27 11:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (184 votes), past polls