perl -e "$sum += $_ while $_ = and chomp; print qq(total: $sum\n)" 1 2 3 4 ^Z total: 10