Introduction to Perl - Executing a Perl Script
Perl is a free programming language known for its ability to quickly
manipulate text files. It is used extensively by programmers on PCs
and UNIX machines to read, modify, and write text files and text-based
databases.
More importantly, Perl has
become the predominant server-based programming language for handling
text-based web pages and is used to accept user inputs (usually from
web page forms) and to use those inputs for real time database updates
and to return custom web pages to users.
The following three sections provide additional introductory information about Perl.
Perl is free, easy to learn, and continues to evolve to meet the
needs of web programmers.
Executing a Perl Script on a PC
The Perl interpreter, "perl.exe", executes Perl scripts. So to run a Perl
script which has been saved in the text file "myscript.pl", open a DOS
window and type the following:
perl myscript.pl
Any filename can be used but .pl and .cgi are extensions commonly used to indicate
Perl scripts.
Executing a Perl Script Remotely
A user can execute a Perl script on a remote web server in two basic ways.
- Hyperlink
A standard hyperlink to the script can be inserted into a web page,
as in this example:
<a href="myscript.pl">Execute a Script</a>
- HTML Form
An HTML form can also be used, as in this example where pressing the
Submit button tells the web server to execute the script "myscript.pl".
<form ...>
</form>
The power of a form is that the value of all elements in the form
are made available to the Perl script when it is executed. This is
ideal for allowing a user to submit information to be used by the Perl
script when it executes.
Capturing Perl Script Output - Returning Output as a Web Page
When a Perl script is executed on a server, its text output can be captured
and returned to the user for display in a browser.
This means that a user can run a Perl script which will generate
an HTML page on the fly, just as though the user had simply clicked on
a link to an existing HTML page.
This on-demand web page generation is the basis for all commercial
sites. The site administrator can focus on updating data without
having to update the pages that display the data.
By the time you go through the tutorials on this site, you'll easily be
able to add this capability to your own web sites.
|