This line tells the CGI what language to run in, and the location.
#!/usr/local/bin/perl
These three lines call the three sub-routines in the script.
&parsedata;
&sendemail;
&printthanks;
This section takes the data from the input stream and converts it into name/value pairs that the CGI program can use.
sub parsedata
{
read(STDIN, $in, $ENV{'CONTENT_LENGTH'});
@in = split(/&/, $in);
foreach $i (0 .. $#in)
{
$in[$i] =~ s/\+/ /g;
$in[$i] =~ s/%(..)/pack("c",hex($1))/ge;
($key, $val) = split(/=/,$in[$i],2);
$in{$key} .= '\0' if (defined($in{$key}));
$in{$key} .= $val;
}
}

