```{index} single: sum0; List::Util function ``` ```{index} single: List::Util::sum0; Perl function ``` # sum0 Add up every value in the list, returning `0` for an empty list. ## Synopsis ```perl my $total = sum0 @values; my $total = sum0 (); # 0, not undef ``` ## What you get back The same number `sum` would produce, except that an empty list yields `0` instead of `undef`. This is almost always what callers want when adding up a list that may legitimately be empty. ## Examples ```perl my $n = sum0 1..10; # 55 my $n = sum0 (); # 0 my $n = sum0 grep { $_ > 0 } @x; # total of positives, 0 if none ``` ## Differences from upstream Fully compatible with upstream. ## See also - `sum` — the original; returns `undef` on empty input. - `product` — identity element for multiplication (returns `1` on empty).