Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: perl script to print just directory names

by davido (Archbishop)
on Dec 07, 2012 at 00:41 UTC ( #1007673=note: print w/ replies, xml ) Need Help??

in reply to perl script to print just directory names

perldoc perlfaq5: How do I traverse a directory tree?

Here's an example:

use Data::Dumper; use File::Find; my $path = '/home'; my @dirs; { no warnings; # Squelch 'permission denied' warning, etc. find( sub { push @dirs, $File::Find::name if -d && ! /^\.\.?$/ }, $path ) } print Dumper \@dirs;

Save yourself some time; spend a half-hour familiarizing yourself with the topics addressed in Perl's FAQ by reading perlfaq, and then refer back to it as needed.


Comment on Re: perl script to print just directory names
Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1007673]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2015-11-25 23:55 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (693 votes), past polls