Add, Subtract, Multiply, and Divide in Perl
Add, Subtract, Multiply, and Divide in Perl:
+ - * /
To add:
$hu=3 + 5;
-The variable we created named $hu now has the value of 8.
To subtract:
$hu=3 - 5;
-The variable we created named $hu now has the value of -2.
To multiply:
$hu=3 * 5;
-The variable we created named $hu now has the value of 15.
To divide:
$hu=3 / 5;
-The variable we created named $hu now has the value of 0.6.
NOTE: When dividing, if you attempt to divide by zero, you will receive a 500 Server Error. This sometimes happens when you are passing a variable and you don't realize that it has no value or is equal to zero... and you forget about this little warning :)
Copy and Paste Perl Code:
#!/usr/bin/perl
print "Content-type:text/html\n\n";
$hu=3 + 5;
print "$hu ";
$hu=3 - 5;
print "$hu ";
$hu=3 * 5;
print "$hu ";
$hu=3 / 5;
print "$hu ";
exit;
Resources:
Use the Perl PRINT FUNCTION
Click HERE to comment or discuss at iLoveTheCode GOOGLE Group