|P is for Practical|
Here is a solution that potentially uses less memory:
Explanation: All of the other options involve copying the return arguments into an array behind the scenes. This does not, instead creating an array with the same number of elements, but containing the value "1" for each element. This will use less memory if the the sub is returning a list of large items (such as long strings).
This would be worth trying if you have problems with high memory usage.
(To test this, see the sample code with memory usage test above)
When's the last time you used duct tape on a duct? --Larry Wall
In reply to Re: Trouble getting size of list returned from sub