Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
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`) - Answer 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);

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 perusing the Monastery: (6)
As of 2016-07-27 19:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What is your favorite alternate name for a (specific) keyboard key?


















    Results (248 votes). Check out past polls.