You are using the assignment operator in your "until" and "if" blocks, and
*not* the comparison operator.  You need to use the double equals for what
you want...

until ($number == 999)

And

if ($number == 999)

Rob


-----Original Message-----
From: Rambog [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 31, 2002 11:10 AM
To: [EMAIL PROTECTED]
Subject: Debug some simple code


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?



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

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

Reply via email to