eval join"+",@_
Of course, that's not safe if @_ includes a text element with a ";" in it.
But in the spirit of silly shortenings, how about some recursion?
sub sum { @_ && pop(@_) + sum(@_) }
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
In reply to Re^2: Golf: Adding up array elements
by xdg
in thread Golf: Adding up array elements
by kwaping
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |