Yeah, sorry, I was just noticing that you had coded it recursively. I didn't notice the recursion and had interpretted your posting as, in part, asking how you would go about rewriting it recursively (to learn about recursion). :-}
No, doing this recursively isn't going to make this unacceptably slow. I think the reason that you ended up with a recursive solution is that your first idea at how to loop through the list of directories went in the "wrong" order (or you chose this order because you wanted to be optimistic and assume that most of the time you don't need to create many directories so start from that end).
Recursion is one way to reverse a loop, but there is usually a "better" way. In fact, in Perl you can use the built-in "stacks" to reverse even the most hard to reverse loop via:
And it is hard to argue that the above is worse than recursion in any way. ;) - tye (but my friends call me "Tye")my @stack; while( <> ) { push @stack, $_; } while( @stack ) { local( $_ )= pop @stack; # your code here }
In reply to (tye)Re2: recursive mkdir
by tye
in thread recursive mkdir
by zzspectrez
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |