All pastes #2133227 Raw Edit

first perl

public text v1 · immutable
#2133227 ·published 2012-03-28 13:39 UTC
rendered paste body
<html>

<head><title>my first form</title></head>

<body>

<h1>my first form</h1>

<form action="cgi-bin/first.pl" method=post>

First name: <input type=text name=fname><br>

Last name: <input type=text name=lname><br>

<input type=submit value=SEND>

</form>

</body>
</html>

=======================================================

#!d:\perl\bin\perl.exe

read STDIN, $buffer, $ENV{'CONTENT_LENGTH'};

if (length ($buffer) > 0){
      @pairs = split(/&/, $buffer);
      foreach $pair (@pairs){
           ($name, $value) = split(/=/, $pair);
           $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
           $value =~ s/\+/ /g;
           $in{$name} = $value; 
      }
 }

print "Content-Type: text/html\n\n";

$ip = $ENV{'REMOTE_ADDR'};

$title = "My first cgi/perl script";

print "<HTML><HEAD>\n<TITLE>$title</TITLE>\n</HEAD>\n";

print "<BODY>\n";

print "<h1>welcome $ip</h1>\n";

$fname = $in{"fname"};
$lname = $in{"lname"};

print "Your first name is <b>$fname</b> and your last name is <b>$lname</b>";

print "</BODY>\n</HTML>\n";