Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
laziness, impatience, and hubris
 
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 romping around the Monastery: (5)
As of 2014-04-20 02:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls