Back to Table of Contents

Analyzing the Perl Script (Reference Only)

There is no need to modify or open the Perl script. FirstClass Web2Form will create and verify the script based on the contents of your template. Below is a the perl script created by the sample template.

Sample Perl Script

The completed Perl Script.

Section 1: Initialization

This section initializes the CGI and specifies that we will use both of the modules that we installed in our Perl site library. This will be required for all of your perl scripts. Note that we have commented out the first line as our AddHandler script manages the location of our Perl libraries.

Section 2: Mandatory Message Field

This section assigns the received message value fields from the form submission to the corresponding variables,

Section 3: Optional Fields

This section assigns the received optional field vales from the form submission to the corresponding variables.

Section 4: Convert date fields

If any date fields are in the template, each one is converted to the FirstClass date format and assigned to a new variable. The script uses the Time::Local perl module.

Section 5: Convert Checkbox fields

If there are any checkbox fields with a submission value of "on" it is converted to the value '1'

Section 6: Converts multiline textarea fields

All text area fields are converted and changes all line feeds to a "->" character.

Section 7: Initiates Mail Headers

The mandatory message field headers are initialized.

Section 8: Form and Icon ID

The Form and Icon ID numbers are added to the message header.

Section 9: Optional Field Headers

The optional fields are added to the message header.

Section 10: Send the Email

The email is sent using the Mail::Sendmail perl module.

Section 11: Notify sender of form submission and redirect

After the message has been sent, a javascript is run alerting the user that the submission has been received. The text used in the alert is specified in the Confirmation message field in the Web2Form template. The user is then redirected to the location specified in the Redirect to: field.