|
||||||
| General Programming Non language specific, Assembly, Linux/Unix, Mac and anything not covered in other topics. Talk about Programming Theory here. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
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. |
| Sponsored Links |
|
|
|
|||
|
whoops! I found my problem. When the program runs through the while loop, there is nothing telling it what '$input' is.
Scope will be my downfall. Feel free to lock, or delete this thread.
__________________
Programming is an art form. Everyone can program, but few can do it right. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Assembly Problem | maple23 | General Programming | 9 | 04-27-2008 05:59 AM |
| Peculiar UI Problem Needs Tackling | adriyel | C# Programming | 2 | 04-06-2008 07:46 AM |
| Problem read pwd protected Access2K dbase - CR9 & VB6 | mrbar | Visual Basic Programming | 2 | 03-10-2008 04:50 AM |
| How to tackle a programming problem? | TcM | General Programming | 10 | 01-07-2008 11:29 AM |
| Javaa:Tutorial - The Loop | John | Java Tutorials | 0 | 12-09-2006 10:01 AM |