Showing posts with label basic math operations in perl. Show all posts
Showing posts with label basic math operations in perl. Show all posts

Friday, October 17, 2014

Basic Math Operations in Perl

I love to learn many things in life programming is not an exception there are thousands of programming language around us. Each one of them has a basic application just like PHP it is design for web development, C and C++ was design to use in system programming that interact with computer hardware and peripherals. One of the programming language that caught in my attention is PERL or Practical Extraction  Reporting Language developed by Larry Wall way back in 1987 to help him in his job as system administrator.

This programming language is often called the swiss army knife in programming community because it has many application not only in console but also in web development.  My experience in Perl is very fundamentals in a sense it is my outlet from my day to day work. I found Perl easy to use and delivers result effectively however in today's IT environment most of the web application specially here in the Philippines uses PHP as their primary language by many web developers maybe because there are many frameworks like WordPress, Drupal and Joomla that is written most of the time in PHP. Again I have to emphasize I do not compare this programming languages because each one of them has a specific application.  

This sample Perl program is my first time to create a web based program using Perl as my programming language. Most of my program in Perl is written in console environment I am using XAMPP as my Perl compiler and interpreter in this sample program. What is program will do is to show the use basic mathematical operations using Perl. The basic math operations are addition, subtraction, division and multiplication. The web browser that is used to run this program is torch a similar browser like google chrome.

If you find my work useful in your programming projects and assignments please send me an email at jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

Thank you very much.


Sample Output of Our Program

Program Listing

#!"D:\xampp\perl\bin\perl.exe"
print "Content-Type: text/html\n\n";

$a=10;
$b=5;
$add = ($a + $b);
$subtract  = ($a - $b);
$multiply = ($a * $b);
$division  = ($a / $b);

print "<hr size='10' color='green'>";
print "<center> <h2> <font color='blue' face='arial'> Basic Math Operations in Perl
  </h3> </center> </font>";
print "<hr size='10' color='green'>";
print "<br>";
print " <font color='red' face='comic sans ms' size='6'>Original Values for variable A is $a and
       for variable B is $b <br> </font>";
print "<br><br>";
print "<font color='blue' face='arial' size='5'>The sum of $a and $b is $add. </font> <br>";
print "<font color='blue' face='arial' size='5'>The difference between $a and $b is $subtract. </font> <br>";
print "<font color='blue' face='arial' size='5'>The product of $a and $b
     is $multiply. </font> <br>";
print "<font color='blue' face='arial' size='5'>The quotient of $a and $b
     is $division. </font> <br>";
print "<br><br>";
print "<font color='blue' face='comic sans ms' size='6'> End of Program</font> <br>";

 

DOWNLOAD SOURCE CODE HERE