Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Deep Directory Listings

Deep Directory Listings

Deep Directory Listings

I have a directory with several levels of sub directories under it. These go down to a level of 4 or 5 in some cases.
I want to create a list of all the directories in the entire tree.

I have been looking at file::find but I don't think it is what I am looking for as it only seems to go down one level.
Is there a module which does a deep directory listing or do I need to roll my own?


RE: Deep Directory Listings


Mine goes deep enough :

CODE --> Keith.pl

use File::Find;

my $max = 0;
my $longest = '';

File::Find::find(sub {
    $depth = scalar @{[$File::Find::name =~ m,/,g]};
    if ($max < $depth) {
        $max = $depth;
        $longest = $File::Find::name;
}, '/');

print "
max        : $max
longest    : $longest
Perl       : $]
File::Find : $File::Find::VERSION

CODE --> commandline

master # perl Keith.pl
max        : 23
longest    : /home/master/.gradle/wrapper/dists/gradle-2.2.1-all/6dibv5rcnnqlfbq9klf8imrndn/gradle-2.2.1/samples/userguide/multiproject/dependencies/java/services/personService/src/test/java/org/gradle/sample/services/PersonServiceTest.java
Perl       : 5.022002
File::Find : 1.29 

Sure the problem is not somewhere else ?


RE: Deep Directory Listings

The gateway just timed out on me so I am not sure what the script just did.

I have been looking at examples of File::Find and they all just go down one level.
I will have a look at it again.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close