develooper Front page | perl.beginners | Postings from January 2002

Debug some simple code

Thread Next
From:
Rambog
Date:
January 31, 2002 08:16
Subject:
Debug some simple code
Message ID:
20020131161651.5007.qmail@onion.perl.org
I am attempting a program that reads a list of numbers from the screen until
the number 999 is read.  It then prints the sum of all numbers read- with
the exception of the 999.

My code looks like:

until ($number=999) {
print "Please input your number:\n";
chomp($number=<STDIN>);
@a=$number;
}
foreach $i (@a) {
$c+=$i;
}
if ($number=999) {
print "Your total is: $c\n"
}

The program immediately terminates with and the line "Your total is:" is
output with a  a blank value.  It never even prompts me to input a number.
What am I doing wrong?



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About