Thread: loop problem
View Single Post
  #1 (permalink)  
Old 05-12-2008, 05:38 PM
suicidal pencil suicidal pencil is offline
Newbie
 
Join Date: May 2008
Posts: 22
Last Blog:
being lazy sucks.
Credits: 0
Rep Power: 2
suicidal pencil is on a distinguished road
Default loop problem

I've been toying with making a calculator in PERL, and I finally finished it!

when I go to run it, it runs perfectly...until it hits the part in the code where it's supposed to go into a loop. When it does, it should wait for me to type something. Instead, it loops the 'else' statement infinitely.

Can anyone help?

Code:
.
.
.
#INPUT
$input = <STDIN>;

print "*\n";

#the beginning portion of the program.

while ($while_lobby == 1){
print "Welcome, to the Command-Line Calculator Version two-point-oh.\n*\n";
sleep(3);
print "For file history, type in \'file history\'.\n*\n";
sleep(1);
print "If this is your first time using this, type in \'help\'\n";
sleep(1);
print "To start your hardcore calculating, type in \'go\'\n*\n";
$while_lobby = 0;
$while_wait = 1;
}

#This while loop patiently waits for you to make a decision.

while ($while_wait == 1){
if ($input eq "help"){
print "$help_block\n";
}
elsif ($input eq "file history"){
print "$file_history\n";
}
elsif ($input eq "go"){
print "going into the calculator. Remember the equal sign at the end!\n";
$while_wait = 0;
$while_calculator = 1;
}
else {
print "Unrecognized command. Type \'help\'\n"
}
}
.
.
.
.
.
__________________
Programming is an art form. Everyone can program, but few can do it right.

Last edited by suicidal pencil; 05-13-2008 at 09:54 AM.
Reply With Quote

Sponsored Links