It looks like I'm loosing my directory handle but I can't figure out why.
DIR is a global filehandle. When you recurse, you re-use that same global directory handle and the previous level's use of it gets over-written.
You have two options:
opendir( my $dh, $dir) or die $!; while ($file = readdir( $dh )) ... open( my $fh, $FullName) or die ...
sub ScanDir { local( DIR, FILE ); ...
One requires minimum changes; the other is seen as the "Modern" option. Both will work.
In reply to Re: Recursion not working
by BrowserUk
in thread Recursion not working
by siggib
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |