Okay, first, this is NOT a homework question for the good reason that I
am not currently in college. I am teaching Perl to myself, and I've
managed to make it to the exercises in Chapter Four of the Llama, Third
Edition and I'm stuck. In this case, RTFMing is not helping (and I'd
rather not resort to the answer in the back of the book). The subroutine
in the attached program is supposed to bring back the sum of the @fred
array and the data input for $user_total. My problem is this, I can get
the subroutine to take <stdin> and it applies it to @fred (which is
wrong), and I can get it to take in <stdin> for the $user_total, but it
doesn't add them.

My question is, what am I not doing right? I don't want the answer to
the program, just a point in the right direction in TFM. BTW, this
exercise is only supposed to take 12 min or so, I've been working on it
for nearly 4 hrs total.
-- 
Dragon Nebula Web Design. It's your universe, take no chances!
http://nebula_web_design.tripod.com
Joseph A Nagy Jr
Owner

#!usr/local/bin/perl -w

my @fred = qw{ 1 3 5 7 9 };
my $fred_total = &total (@fred);
print "The total of \@fred is $fred_total.\n";
print "Enter some numbers on separate lines: ";
my $user_total = &total (<STDIN>);
print "The total of those numbers is $user_total.\n";

sub total {
  ($fred_total...$fred_total +=) ;
  (<stdin>...<stdin> +=) ;
 }

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to