in reply to Recursive sub efficiency
Bugs should be a bigger concern.
You're treating text as a regex pattern in s/$topdir/$recreate_to/.
s/\Q$topdir/$recreate_to/
You're using an unlocalised global (*DIR) in a recursive function. You're not using it in a way that would cause a problem, but why?!
opendir (local *DIR,$dir) || die "unable top open dir $dir $!"; my @files = grep(/\w+/,readdir(DIR)); closedir (DIR);
Better:
opendir (my $dh,$dir) || die "unable top open dir $dir $!"; my @files = grep(/\w+/,readdir($dh)); closedir ($dh);
Update: s/close/closedir/
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Recursive sub efficiency
by skywalker (Beadle) on Jun 10, 2010 at 19:44 UTC | |
by ikegami (Patriarch) on Jun 10, 2010 at 20:24 UTC |