The obvious way to golf it:
sub sum { my$t;$t+=$_ for@_;$t }
The eval approaches are shorter, but unsafe. It’s your call whether that’s acceptable. For real code, it’s not. But in real code I’d use List::Util.
Update: added space as per sauoq.
Makeshifts last the longest.
In reply to Re: Golf: Adding up array elements
by Aristotle
in thread Golf: Adding up array elements
by kwaping
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |