ThePlace

Home ] Search ] Resources ] Site Map ] Contact Me ]
Dave's Information Technology Resource

Up ] Simple Example ] Mail Program in Perl ]

DHTML ] CSS ] JavaScript ] ActiveX and Plug-ins ] VBScript ] Web Applications ] ASP ] Web Databases ] ASP Applications ] [ Perl ] Java ]

--- Perl ---

Background on Perl

(adapted from http://www.perl.com/pub/qa/What_is_Perl? )

bulletPerl is an interpreted high-level programming language developed by Larry Wall. 
bulletPerl has become the premier scripting language of the Web, as many CGI programs are written in Perl. 
bulletPerl is widely used as a rapid prototyping language and a "glue" language that makes it possible for different systems to work well together. 
bulletPerl is popular with system administrators (UNIX) who use it for an infinite number of automation tasks.
bulletPerl's roots are in UNIX but you will find Perl on a wide range of computing platforms. Because Perl is an interpreted language, Perl programs are highly portable across systems.
bulletFinally, Perl is more than a programming language. It is a part of the Internet culture. It is a very creative way of thinking about almost anything.

What is a Perl Program

bulletA collection of statements that are collected in a file and are then interpreted at run time.  This collection of statements is often called a "script".
bulletPerl scripts include the following structure:

includes ... /usr/bin/PERL

variables...$username='John Smith'; (scalar data, strings and numbers - single values, double quoted strings operate similar to C)
@months - (Jan, Feb, Mar...);
(lists, arrays of strings and numbers; the array starts with 0)

input...read(STDIN, $buffer, $ENV('CONTENT_LENGTH'));

Perl depends on STDIN and STDOUT (formed as <STDIN> and <STDOUT>)

#comments - starting with the #

actions...such as concatenation using the  .  operator or .=

much of the string/number processing is similar to C/Java

statement blocks are contained in { } and include if/unless, while/unitl, do{} while/until, for, foreach

Perl is well known for "hashes" which are arrays accessed by keys - Perl manages where the data is stored and you can reference with "key words".  Hash identifiers are indicated by the % followed by a letter, followed by zero or more letters, digits, or underscores..

functions - sub subname {

statement_1;

statement_2;

}

functions are invoked by ... subname(); 
parameters can be passed with the  [value] 

Review the Perl script example

Using Perl

Assumes you have a Perl interpreter available (fairly common on Unix systems, not as common on NT-based systems).  If in doubt, check with your system administrator.

Make sure you have execute privileges so that your scripts can run.  Many servers are set up to only allow scripts to be run in certain directories (often with a CGI-BIN name).

Remember that Perl, because of Unix, can be case sensitive.

Web Sites for Perl

bulletwww.perl.com - great starting point for scripts, samples, and updates on Perl.
bulletwww.activestate.com/ - ActiveState distributes a Perl for Windows NT.
bulletwww.worldwidemart.com/scripts/cgi-bin/download.cgi - Matt's Script Archive, one of the great resources for web scripts

Books for Perl

There are dozens of books on Perl.  O'Reilly does a number of them that are worth reading and using.  Like most books, decide what you need it for--to review the language, apply it (examples needed), or integrate it with other applications (e.g., databases, client scripting, etc.).

bulletLearning Perl on Win32 Systems, Schwartz, Olson & Christiansen, O'Reilly, 1997
bulletO'Reilly has a number of very good books including...Perl in a Nutshell, Perl Cookbook, Learning Perl (very good), Regular Expressions, Perl/Tk
bulletA number of books by Que, Sams, etc.  (there may be more books on Perl than HTML...). 

 

 

Home ] Up ] Computer Architecture ] Programming Bootcamp ] Database Bootcamp ] Visual BasicS ] Web Basics ] Web Multimedia ] Advanced Web Topics ] Developing Web Sites ] XML Technology ] Web Glossary ]

Copyright © 1999 - 2005 
ThePlace - Written and Sponsored by Dave Hillman