It looks like you only operate on sub-directories, and you just discard files. I'm not sure if it is more efficient (speed and/or memory) without Benchmarking, but the code would be more straightforward if you filtered out what you didn't need in the grep:my @files = grep(/\w+/,readdir(DIR)); close (DIR); foreach my $subdir (@files){ if(-d $dir.'/'.$subdir){
Update: Fixed -d and closedirmy @dirs = grep { /\w/ and -d "$dir/$_" } readdir(DIR); closedir (DIR); foreach my $subdir (@dirs){
In reply to Re: Recursive sub efficiency
by toolic
in thread Recursive sub efficiency
by skywalker
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |