spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / web / programming / perl / 101 / program

The Program

Developer News
Mandrake Linux Founder Back, Virtually
Amazon: We're a Technology Company
Sun Expands MySQL With Closed Source

Perl 101

Our program will not do anything terribly useful. It is a simple program that will illustrate some essential aspects of installing a Perl program, while acquainting you with your FTP program and some basic Perl syntax. Our program is designed to be called as a server side include (it is called invisibly from a web page and will record some basic information). The first step of our installation will require very little configuration and will test to see if you uploaded the file correctly and set the correct permissions. Let’s begin by looking at the program (it is available here for download). Open the program up in your text editor and examine the first couple lines of your program, which should read:

1 #!/usr/bin/perl
2 # This line says "Hey, Man, I'm a Perl program!"
3 # It points to the Location of the Perl Interpreter on your server.
4 # This tells the server that your program
5 # needs to be interpreted/executed
6 # Some windows environments will not require this line

The first line tells the server that the program needs to be interpreted and points to the location of Perl on your server. You should consult your ISP to find the exact path (sometimes it is #!/usr/local/bin/perl). Lines 2-6 are standard Perl comments. Anything after the # is considered a comment and is not processed by the Perl interpreter (the first line being the exception). A comment can appear anywhere in a Perl program, even after a valid expression. If you have the program pointing to the correct location of Perl on your system we can now upload it (in ASCII or text mode) to the server. Some ISP’s or servers require that you place all of your scripts in the /cg-local/ or /cgi-bin/ directory, while others will allow you to execute a script in any folder or directory. You should again consult your ISP to find out. After you upload the script to the appropriate directory, let’s set it’s permissions, or chmod the file 755 as in the above matrix example.

After you have done this, it is time to see if you have done it right. Launch your Internet browser and type in the URL to your script (http://www.yourdomain.com/cgi-bin/script.cgi?exec). You will notice that I added on a query string at the end of the script name. By adding the ? and the word exec, I am calling a specific function of the script, or passing it a query string. If the script was uploaded correctly and the permissions were correctly set you should see:

Hey, Man, it worked!
I’m executed!
Wednesday April 29, 1998

If it worked, congratulations! If it didn’t work, skip ahead to the trouble shooting section to see if you can figure out what is wrong.

Comments are welcome

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

webref The latest from WebReference.com Browse >
Working with the DOM Stylesheets Collection · Administering RBAC in PHP 5 CMS Framework · xref: Automatic Cross Referencing Script
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Combine BottomCount() with Other MDX Functions to Add Sophistication · Creating a Daemon with Python · The Coming Voice-over-WiMAX Revolution


Revised: May 8, 1998

URL: http://webreference.com/programming/perl/101/program.html