Honestly, I don't know how big a waste of memory it is. When it comes to recursive functions, having a big state can be a problem. It's a good idea to avoid a large state unless you can show it's not a problem rather than the other way around. Factoring out unchanging variables is an easy and low-cost way of reducing the size of the state.
It would be a bigger problem in another language where the stack has a limited size. Perl dynamically allocates each stack frame on the heap, so it's not limited like in C.
In reply to Re^4: passing subroutine references
by ikegami
in thread passing subroutine references
by joe76
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |