Hello great monks!
I have a design problem, which ought to be simple but is confounding me. I have a package containing a variety of functions to help me deal with my data, which is in large arrays. I am having troubles abstracting a change to my code. Currently I have:
sub processA { # common stuff # special stuff } sub processB { loop (1..1000) { # common stuff # special stuff } }
I want to make this into something more modularized for a variety of reasons, so I was considering something like this:
sub processA { common_stuff($); # special stuff } sub processB { loop (1..1000) { common_stuff($); # special stuff } } sub common_stuff { # common stuff }
Pretty straight-forward, I guess. The problem is that as it stands now, the repeated code section (#common stuff) constructs a large array, then manipulates it. With my proposed modification, I would be creating this array for every iteration of the loop in processB. That isn't acceptable from a performance stand-point. So, I want something that may not be possible (or that may be, and I just don't know the term for it!):
Basically I want some way to create a large array in a sub-routine, keep it around as long as I need, and then to get rid of it. And preferrably I'd still want to keep this all in a single package.
Am I dreaming, or misguided, or naive, or lost? :)
In reply to Design Question by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |