in reply to Use of uninitialized value in addition

If you have 5 values, $total is 5 and the values in are in $value[0] to $value[4]
for my $valNum (0 .. $total){
should be
for my $valNum (0 .. $total-1){