use warnings; use strict; my $tot = 0; while () { my ($num, $date) = split; $tot += $num; printf "%-5d %s\n", $tot, $date; } __DATA__ 1 2005-01-16 6 2005-01-28 1 2005-01-31 2 2005-02-01 2 2005-02-02 1 2005-02-05