Change until ($number=999) {
and if ($number=999) { to == 999. You are assigning the value 999 to the $number var in both cases, not checking if it is equal to 999. Simple mistake, we've all made it ;) HTH John P.S Here is how I would code this script. use strict; my ($number, $total); until ($number == 999) { print "Please input your number: "; chomp($number=<STDIN>); $total += $number unless $number == 999; } print "Your total is: $total\n" -----Original Message----- From: Rambog [mailto:[EMAIL PROTECTED]] Sent: 31 January 2002 16:10 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] --------------------------Confidentiality--------------------------. This E-mail is confidential. It should not be read, copied, disclosed or used by any person other than the intended recipient. Unauthorised use, disclosure or copying by whatever medium is strictly prohibited and may be unlawful. If you have received this E-mail in error please contact the sender immediately and delete the E-mail from your system. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]