Traversing directory recursively

2015-07-09 Thread Nagy Tamas (TVI-GmbH)
Hi, So I have a better version. But if it goes down in the recursion tree, at the end it goes into infinite loop, because there is no other dir inside the last dir in the tree. At this point it has to step back. But instead of stepping back it goes into infinite loop. Why? sub Traverse {

Re: Traversing directory recursively

2015-07-09 Thread Jim Gibson
On Jul 9, 2015, at 8:27 AM, Nagy Tamas (TVI-GmbH) tamas.n...@tvi-gmbh.de wrote: Hi, So I have a better version. But if it goes down in the recursion tree, at the end it goes into infinite loop, because there is no other dir inside the last dir in the tree. At this point it has to

Re: Traversing directory recursively

2015-07-09 Thread Uri Guttman
On 07/09/2015 01:19 PM, Jim Gibson wrote: It is because you are calling the Traverse() subroutine with two arguments to recurse a directory tree, but you are not using the arguments. Each call to Traverse uses the global $dir variable as the root of the tree, so it will never terminate. You

Re: Printing dir into XML

2015-07-09 Thread Ken Slater
On Thu, Jul 9, 2015 at 6:01 AM, Nagy Tamas (TVI-GmbH) tamas.n...@tvi-gmbh.de wrote: Hi, The following code doesn’t recognize dirs. As I list the dir into the XML, it shows dirs as ordinary files. Like the –d would not work. If I add an extra branch to recognize files with –f, it

Printing dir into XML

2015-07-09 Thread Nagy Tamas (TVI-GmbH)
Hi, The following code doesn't recognize dirs. As I list the dir into the XML, it shows dirs as ordinary files. Like the -d would not work. If I add an extra branch to recognize files with -f, it doesn't print either files at all nor dirs. sub Traverse { opendir(DIR, $dir) or