good chemistry is complicated,
and a little bit messy -LW
Trouble getting size of list returned from subby wanna_code_perl (Pilgrim)
|on Nov 26, 2012 at 08:53 UTC||Need Help??|
wanna_code_perl has asked for the
wisdom of the Perl Monks concerning the following question:
I'll confess to feeling rather foolish right now. I have to work with a sub that is returning a list directly, and I don't need the contents of the list; just the number of elements, but I can't figure out how to do so without a temp variable. Here's a simplified example:
I can accomplish what I want with this clumsy mess:
Is there no way to avoid the temp variable? And will Perl actually create a copy of the list in that case? My typical solution set is in the thousands.
As for the sub itself, it's someone else's XS code that I'm loathe to modify (not just something I can stick a wantarray in...), but I will if absolutely necessary.