"be consistent" | |
PerlMonks |
Re^2: Is it possible to create a sub exclusive to a sub?by FoxtrotUniform (Prior) |
on Sep 19, 2004 at 02:27 UTC ( [id://392090]=note: print w/replies, xml ) | Need Help?? |
Yes, stacks of nested subs are super-cool. But, uh, why bother writing all recursive code this way? I don't see any gain in efficiency (if anything, creating all those subs might slow things down a tad), and it introduces an extra level of "WTF?" to people reading the code. On the other hand, if you're writing tail-recursive code, this is a great way of not exposing an accumulator variable to the rest of the world. For example (untested): Also, have a look at Just Another Godel, Escher, Bach hacker. Edit: Separated declaration and use of $fact_tr. Thanks ihb! --
In Section
Seekers of Perl Wisdom
|
|