Hi,
I am doing some homework from the book Learning Perl chapter 4 excercise 1,
Looking at the script below, I wonder why line 6 (print "Enter some numbers on
separate line: ";) is not printed immediately after the previous print.
Thanks
use strict;
use warnings;
my @fred = qw/1 3 5 7 9/;
my $fred_total = &total(@fred);
print "The total of [EMAIL PROTECTED] is $fred_total.\n";
print "Enter some numbers on separate line: "; ## line 6
my $user_total = &total(<STDIN>);
print "the total of those numbers is $user_total.\n";
sub total {
my $sum;
foreach (@_){
$sum += $_;
}
$sum;
}