in reply to Summing numbers

Nothing is actually wrong with your code. Enter numbers one per line.
$type 1226028.pl use feature qw(say state); say "Please input numbers to be summed. Crtl-D to stop"; my $user_total = &total(<STDIN>); chomp($user_total); print "The total of inputted numbers is $user_total \n"; sub total { state $sum = 0; state $number; foreach my $number (@_) { $sum += $number; } return $sum; } $perl 1226028.pl Please input numbers to be summed. Crtl-D to stop 12 12 ^Z The total of inputted numbers is 24
Note: I added 'feature' statement and used CTRL-Z rather than CTRL-D
Bill