$old += ($time - $old >= $period) ? $period : 0; ... my ($size , ...); $size += $_ foreach @raw;