in reply to Re: (tye)Re: recursive mkdir
in thread recursive mkdir

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:

my @stack; while( <> ) { push @stack, $_; } while( @stack ) { local( $_ )= pop @stack; # your code here }
And it is hard to argue that the above is worse than recursion in any way. ;)

        - tye (but my friends call me "Tye")