Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

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

by toolic (Bishop)
on Aug 15, 2009 at 17:50 UTC ( [id://788916]=note: print w/replies, xml ) Need Help??


in reply to How do I find directories within directories using : parse_dir(`ls -l`)

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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://788916]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-18 21:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found