![]() |
|
Just another Perl shrine | |
PerlMonks |
Re^3: Trouble getting size of list returned from subby ColonelPanic (Friar) |
on Nov 26, 2012 at 12:25 UTC ( [id://1005629]=note: print w/replies, xml ) | Need Help?? |
Actually, it is not a scoping issue. By that logic, this should also save memory:
However, in a simple test, that uses the same memory as a global array that does the same thing. Perl, generally speaking, does not release memory back to the OS unless your system is running out of memory. The memory from lexical variables can be claimed and reused by Perl, but it doesn't go back to the OS. All of the other methods created an array in addition to what was copied on the stack. map only creates an array of 1s in addition to what was copied on the stack; thus it uses less memory (unless your original data is no bigger than integers, of course) (and yes, this was not always true in older versions of Perl). When's the last time you used duct tape on a duct? --Larry Wall
In Section
Seekers of Perl Wisdom
|
|