Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
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 chilling in the Monastery: (9)
As of 2014-12-21 05:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (103 votes), past polls