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`)

by toolic (Bishop)
on Aug 15, 2009 at 17:50 UTC ( #788916=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

Assuming you're using the parse_dir function from the File::Listing module...

The following will populate the @dirs array with the names of the sub-directories in the current directory (excluding all hidden directories which begin with the dot character):

use File::Listing qw(parse_dir); my @dirs = map { my( $name, $type ) = @$_; $type eq 'd' ? $name : () } + parse_dir(`ls -l`);

To include 'dot' directories (except for the special . and .. directories), you'd simply use ls -la:

my @dirs = map { my( $name, $type ) = @$_; $type eq 'd' ? $name : () } + parse_dir(`ls -la`);

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 browsing the Monastery: (2)
As of 2016-10-01 02:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (574 votes). Check out past polls.