note
kennethk
<blockquote><i>The regex suggested by tobyink above can make the single-line case much more readable</i></blockquote>
<p>The advantage of mine is that it actually enforces format, which may or may not be of concern. I also like that you expect two values and you get two values; a little less slight of hand for maintenance. But I do appreciate the elegance of his choice of indices.
<p>Also be aware you'll need to initialize <c>@totals = (0,0)</c> so that the index <c>-1</c> doesn't map to your first term. [tobyink] does it, but didn't really emphasize its importance.
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-712372">
<hr />
<p>#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.</p>
</div></div>
994298
994317