| scuzzman |
Dec 23rd, 2005 5:29 AM |
A simple script isn't working correctly
I'm having trouble getting a very simple script to run and cannot figure out the problem. The script is as follows:
:
#!/usr/bin/perl -w
$level = 1;
$prod = (20 * $level) * (1.1 ** $level);
print "What is the amount of energy you\'re trying to accumulate? ";
chomp ( $goal = <STDIN> );
while ($prod <= $goal) {
# print "$level\n"; # DEBUG: print the current level
$level++;
}
print "\nRequired level for $goal energy from a solar planet is $level\n";
The problem is that the $prod never changes from 22 (which is what it evaluates to when $level = 1). Because $prod is based on the value of $level, shouldn't $prod change when $level does?
|