Note: I added 'feature' statement and used CTRL-Z rather than CTRL-D$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
In reply to Re: Summing numbers
by BillKSmith
in thread Summing numbers
by catfish1116
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |