use List::Util qw/ pairmap /; sub a_pairmap { my $i; pairmap { $i += $b } @vals; return $i; }