Keep It Simple, Stupid | |
PerlMonks |
Re^2: Depth Listing in Directory Traversalby crabbdean (Pilgrim) |
on Jul 20, 2004 at 04:56 UTC ( [id://375803]=note: print w/replies, xml ) | Need Help?? |
Well I'm not sure this will work because the code makes the program go down the directory first, not across. Based on your idea it would have to keep a record somehow of the $oldir variable for when it finally finished going down the tree and came back to start on the next level. This requires it to keep a kind of memory of the tree and what it has or hasn't done. There must a simpler way. BUT ... your idea has merit and something I'd considered also - your post has made me rethink it. If the number of path seperators is greater than $depth then don't push to the stack. That may work. I just don't like using relying on counting "\" in strings as a reliable method of keeping track of depth. If by chance a directory has that character in it, the routine will fail. 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
In Section
Seekers of Perl Wisdom
|
|