in reply to recursive path function falls into infinite loop
This is designed to work on a Mac (see the : directory separators) and also designed to spider whatever directory the script is in (hence no $base definition, and two lines of code making sure the script itself isn't messed with).use strict; use warnings; my ($dir, $file, $path); my ($script) = $0 =~ /:?([^:]+)$/; my @dirs = ':'; while ($dir = shift(@dirs)) { opendir(DIR, $dir); while ($file = readdir(DIR)) { next if $file eq $script; $path = "$dir$file"; if (-d $path) { push (@dirs, "$path:"); next; } ######### # Open each $path and process ######### } }
Just another viewpoint. This is a regular question, and probably the third time I've posted this to various threads.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re^2: recursive path function falls into infinite loop
by merlyn (Sage) on Nov 25, 2004 at 15:47 UTC |