The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 02-09-2009
daddygrant daddygrant is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 5
Short code driving me nuts.

Hello guys I am trying to learn perl and have a simple calculator I am trying to run but I get error runaway multi-line. Can someone point this rookie in the right direction.


###

print 'Welcome to the Calculator';
print 'Would you like to enter the calculator? Please Type y or n';
$run = <stdin>;
chomp $run;
while ($run == y)
{
{
print 'Add = a | Subtract = s | Multiply = m | Divide = d |Exponent = e | Mod = O ';
print 'Enter the corresponding number to the caluclation to be performed:';
$calc = <stdin>;
chomp $calc;
print 'Please enter the first value: ';
$A = <stdin>;
chomp $A;
print 'Please enter the second value: ';
$B = <stdin>;
chomp $B;

if($calc == a)
{
$answer = $A + $B;
}
elsif($calc == s)
{
$answer = $A - $B;
}
elsif($calc == m)
{
$answer = $A * $B;
}
elsif($calc == d)
{
$answer = $A / $B;
}
elsif($calc == e)
{
$answer = $A ** $B;
}
elsif($calc == o)
{
$answer = $A % $B;
}
print "The answer is $answer .";
}
print 'Would you like to perform another calculation? Please Type y or n';
$run = <stdin>;
chomp = $run;
}


print 'The application is now terminated.';

###

Last edited by daddygrant; 02-09-2009 at 01:14 PM..