|
|
This is the Perl Script for 'test.pl' (Testing Forms):
|
|
|
(01)#!/usr/bin/perl -w (02)if ($ENV{'REQUEST_METHOD'} eq 'GET') { (03) @pairs = split(/&/, $ENV{'QUERY_STRING'}); (04)} elsif ($ENV{'REQUEST_METHOD'} eq 'POST') { (05) read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); (06) @pairs = split(/&/, $buffer); (07)} else { (08) &error('request_method'); (09)} (10)print "Content-Type: text/html\n\n" (11)print "<HTML><BODY BGCOLOR=\"\#FFFFFF\">\n" (12)print "<CENTER>\n" (13)print "<TABLE BORDER=1>\n" (14)foreach $pair (@pairs) { (15) local($name, $value) = split(/=/, $pair); (16) $value =~ tr/+/ /; (17) $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; (18) # strip off any possible SSI comment tags. (19) $value =~ s/<!--(.|\n)*-->//g; (20) $in{$name} = $value; (21) print "<TR><TD ALIGN=RIGHT>$name:</TD><TD>$in{$name}</TD></TR>\n" (22)} (23)print "</TABLE>\n" (24)print "</CENTER>\n" (25)print "</BODY></HTML>\n" (26)exit; |
(01)<-- Run Perl (02)<-- Check if the ACTION was a GET (03)<-- Split the $buffer into an Array (04)<-- Check if the ACTION was a POST (05)<-- Read in the Environment Variable (06)<-- Split the $buffer into an Array (07)<-- ELSE if neither GET nor POST (08)<-- Return an Error (09)<-- Close the IF (10)<-- Return the HTML Content Type (11)<-- Put the HTML Header Info (12)<-- Center (13)<-- Put out the Table (14)<-- Load the Array into a String (15)<-- Split the String into Two Strings (16)<-- Remove any Plus Signs (17)<-- Substitute out Invalid Characters (18)<-- a Comment (19)<-- Clear Security Problems (20)<-- Create Another Array (21)<-- Print the Two Values to the Table (22)<-- Close the foreach Command (23)<-- Put the Table Close (24)<-- Put the Center Close (25)<-- Put the HTML Close (26)<-- Exit Perl |
|
This Code will execute 'test.pl': All Tutorials are Intended to be Totally Harmless, Secure and Safe. No Information is being retrieved from you or your personal computer. |
|
View the Perl Tour, with Coding Syntax here. |
Back to the Table of Contents