|
How To Write A PERL
Program
Perl can basically call any of
the system functions and is an interface between the users and
any program that the server can run via the program you write.
One ability perl has, like any
other computer function is to handle math functions. Basic adding
and subtracting to trig and complex math equations.
Lets say we want to add 2
numbers,10 and 15.
Using a varriable just like in
algebra, we write:
$numbersadded = (10 +
15);
Then we tell the program to
print the answer.
print "$numbersadded";
#!/usr/bin/perl
print "Content-type: text/html\n\n";
$numbersadded = (10 + 15);
print "$numbersadded";
When we access out test program with the
browser, it will simply show "25".
This is very useful when we want to add up
the cost of items in a shopping cart or make some calculation
that will determine the next step the the program. For example if
the total shopping cart order is not greater than 0, you wont
allow the person to go to the checkout.
The basics are very basic, but it is these
basic functions that add up to become very complex programs that
run banking systems and huge businesses and databases.
Most e-commerce programs will never require
knowing more than addition, subtraction, multiplication and
division. There is no need to study all of the math functions
unless you are writing software for engineering applications.
PREVIOUS <<
|