Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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.


Dave


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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (10)
As of 2014-10-21 22:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (111 votes), past polls