in reply to Recursive tree walk with scoping issues
This is a classic error with global filehandles. Your recursive routine dir_size() opens the DIR handle at each level it's called. That closes the previous opening of it, invalidating the handle after the inner call returns. You can repair that in line 22 with,
respelling the handle name everywhere in the lexical version.opendir local(*DIR), $dir or die "Unable to open $dir: $!"; # or # opendir my $dh, $dir or die "Unable to open $dir: $!";
After Compline,
Zaxo
|
|---|