I like the straightforward,
push @result, func1([ splice @_, 0, $num_elements ]) while @_;
but this expression could not be placed in a sub's parameter list because push
does not return a list, rather it returns the number of new elements in the list.
To clarify, this technique is used primarily to transform function parameters before they get passed. I could not use your two step method for that case. This technique is useful for creating HTML tables with N columns, where Tr() and td() both accept array refs. And, in order to fold the list without breaking stride, I used map.
As a side note, I have been programming in Lisp for the last couple months, so I'll admit that this technique appears more functional than procedural. :-)
What time is it? It's Camel Time!
P.S. A matter of opinion:
two steps is right? Just because our styles are different does not make either one of them right or wrong. It's a bit strong to say that your code is right, because that implies that my code is wrong. Let's agree that it is *your opinion* that "two steps" is the right/better way or *you prefer* "two steps." As a highly respected individual in this community, you affect the perceived usefulness of every node on which you comment. And I, for one, don't want to believe that you are an arrogant person, so please update your node to reflect that it *is* your opinion rather than a matter of fact.