Basic Perl for the Web by Project by ojp13483

VIEWS: 4 PAGES: 2

									                              Basic Perl for the Web by Project
Introduction to Perl

       The Perl Language

       UNIX language, interpreted, cgi scripts for the web. Created in a text editor. Resides in an
       execute-enabled directory. File extension is not important, but is often .prl or .pl. Perl interpreter
       program must be in the path. Interpreter is free.

       Common Uses of Perl on the Web

       Form processing, database processing & searching. Can be used for automatic functions, such as
       automatic email responses. Math capabilities allow it to be used for calculating prices, tax, shipping, etc.

Programming Conventions

       End command lines with semi-colon (;). Indent sections for reading clarity. Comments. List subroutines.
       Then program flow. Open and close files as needed. Clearly declare variables.

Printing to the Screen

       Create an order response that can be used in an order processing program, “Thank you for placing your
       order with us!” Add a second line, “Please allow at least two weeks for processing and delivery.” Add
       html tags to make line 1 font +2 and bold, line two font +1 and italics.

Saving Input to a File

       Opening and closing files. Creating a new file. Writing to files. Save the response to a file that could be
       emailed to the customer or used for later tracking.

Operators & Variables

       Types of operators (assignment & comparison). Types of variables (scalar & array). Scalar variables start
       with $. Assigning a value to a variable. Doing math (add tax or shipping).



Using an HTML Form to Trigger and Provide Input for a Perl Script

       Create a basic form processing program that takes the output from an html form and lists each item after
       its control name in a file. Add line breaks between items.

Conditions (If)

       „If statement‟ structure (If, Elsif, Else). Calculate tax IF state != NM. Print IF $name !=“”. Using
       multiple conditions. AND and OR conditions.

Using Lists & Arrays

       List=several scalar values separated by commas and enclosed in parentheses. Can be used as an array.
       Array variables begin with @ and contain a list of values. Values in an array are numbered starting with
       0.
Autoincrement and Autodecrement

      Using ++ and -- to automatically increase or decrease a scalar variable value.

Loops with For & Foreach

   Control the number of times a routine repeats using FOR. Changing the operator (>, <, =, <=, etc.). Using a
   variable for the upper number in a FOR statement.

   Repeating a routine for each item in an array with FOREACH.

								
To top