in reply to Recursive sub efficiency
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){
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Recursive sub efficiency
by skywalker (Beadle) on Jun 10, 2010 at 19:56 UTC | |
by ikegami (Patriarch) on Jun 10, 2010 at 20:27 UTC | |
by toolic (Bishop) on Jun 10, 2010 at 20:23 UTC |