Perl Monk, Perl Meditation | |
PerlMonks |
Depth Listing in Directory Traversalby crabbdean (Pilgrim) |
on Jul 20, 2004 at 03:32 UTC ( [id://375782]=perlquestion: print w/replies, xml ) | Need Help?? |
crabbdean has asked for the wisdom of the Perl Monks concerning the following question:
For this I'll refer to a previous node 349582 and especially tye's response to that node 350948 in which he describes a "next" method iterator. I've since used the guts of this "next" method (Big Thanks to tye) in a module I'm writing. I'm wanting to amend that method so that you can specify it to only go so deep into the directory tree. Here is the code: As you can see in this code I've put in the checks for the $self->{level} in that it will only push to the $self->{dirs} stack if the current level is below the specified depth or depth == -1 (if depth is set to -1 it will fully recurse the directory tree) I'm having trouble building into this how to track the depth to ensure it only goes as far as specified. Any suggestions? Update: I should add that what makes this tricky is the code makes it go DOWN a directory tree first before starting on the next level, not across the directory tree as is usually the case. Dean The Funkster of Mirth Programming these days takes more than a lone avenger with a compiler. - sam RFC1149: A Standard for the Transmission of IP Datagrams on Avian Carriers
Back to
Seekers of Perl Wisdom
|
|