in reply to Re: Re: Recursive opendir without
in thread Recursive opendir without
I assume that you mean "why my opendir($dh,$dir) doesn't work". That is because when you opendir($dh,"/") and then readdir($dh), you'll get a file name like "usr" and then try to do opendir($dh,"usr") which isn't the same as opendir($dh,"/usr"). If your current working directory happens to be "/", then that call will work (by luck) and you'll read a file name like "home" and try opendir($dh,"home") when you should be doing opendir($dh,"/usr/home").
So you either need to chdir into each directory before you open the next one (and then chdir back out when you are done) or you need to keep track of the full path to each directory as you go so you can prepend it in several places.
- tye (but my friends call me "Tye")
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (tye)Re: Recursive opendir without
by bobione (Pilgrim) on Apr 11, 2001 at 21:52 UTC | |
by tilly (Archbishop) on Apr 12, 2001 at 06:04 UTC | |
by bobione (Pilgrim) on Apr 12, 2001 at 15:28 UTC |