foo {
chdir ($_[0]);
opendir (CURRENT_DIR, ".");
while ($name = readdir(CURRENT_DIR)) {
do_stuff();
if (-d $name && $name ne "." && $name ne "..") {
foo($name);
}
}
}
But that doesn't work because the directory handle gets overwritten in each recursion. Is there any way of declaring directory handles private, as you would with my($var). I am humbled before the majesty of perl.
In reply to Using directory handles in recursive functions by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |