Background on Perl
(adapted from http://www.perl.com/pub/qa/What_is_Perl?
)
 | Perl is an interpreted high-level programming language developed by
Larry Wall. |
 | Perl has become the premier scripting language of the Web, as many CGI
programs are written in Perl. |
 | Perl is widely used as a rapid prototyping language and a
"glue" language that makes it possible for different systems to
work well together. |
 | Perl is popular with system administrators (UNIX) who use it for an
infinite number of automation tasks. |
 | Perl'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. |
 | Finally, 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
 | A 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". |
 | Perl 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
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.).
 | Learning Perl on Win32 Systems, Schwartz, Olson & Christiansen,
O'Reilly, 1997 |
 | O'Reilly has a number of very good books including...Perl in a
Nutshell, Perl Cookbook, Learning Perl (very good), Regular
Expressions, Perl/Tk |
 | A number of books by Que, Sams, etc. (there may be more books on
Perl than HTML...). |
|