in reply to Re: Builing a Recursive Directory Listing
in thread Builing a Recursive Directory Listing
This approach is frowned upon in the general case, because if you follow symbolic links. If a chain of symbolic links ever gets back to above where you are in the the directory tree, you will have created a loop, and your program will never terminate.
update: Duh! I skimmed too much and missed the -l test. Sorry sporty, bad me. I guess after having seen half a dozen wrong solutions posted here over the years one starts to expect them to be all wrong. Which by extension is another reason to use File::Find, it offers a much higher level of conceptual chunking.
It might be something as simple as foo -> ../../../ but it might also be something more subtle: foo -> /bar/new/foo and something in /bar/new/foo points back here again. In my experience it's always1 been something fairly obscure, always involving new versions of applications and new disks being added to the machine. After a few years, this sort of cruft builds up and makes the scenario inevitable.
The File::Find modules take care this problem into account, and can thereby save you from shooting yourself in the foot.
Maybe I should point out that I'm not pointing the bone at sporty, but rather warning those who'll see this in the future and think that this would be a better approach than to use standard modules, NIH syndrome and all that.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re:x2 Builing a Recursive Directory Listing (beware of loops)
by exussum0 (Vicar) on Dec 15, 2003 at 13:49 UTC |