|Syntactic Confectionery Delight
scoping large arrays - newbie Qby moof1138 (Curate)
|on Jun 18, 2002 at 04:00 UTC
moof1138 has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks, I have a script in which I have a few arrays of about 100 strings, each string being about 200 characters long, give or take. When I wrote this thing I declared them in the main scope, even though some arrays are only really used by one function, assuming that it was better loading them once right at the beginning, since otherwise they would be pushed into memory anew each time the function was called, slowing things down a little. Now I wonder if this might actually not be the case. Is it better to put the arrays in the scope of the function that is using them, leave them scoped as they are now, or does it matter at all, and why? Any thoughts appreciated.