M
Mark Tarver
I'm writing my first significant Perl CGI script. Its supposed to read
in the input from two forms and print them on the screen. The preamble
seems to work fine - takes the input string and spilts it into the
component tokens. The print HTML bit does not work fine. What
appears on the browser
is:
Info
--------------------------------------------------------------------------------
Name:
Email:
with neither values of name or email displayed. Why is this?
A minor niggle - Perl does not seem to match END_OF_PART2 unless I
place the redundant print statement at the bottom. No idea why.
Mark
# Here is the Code
#!/usr/bin/perl
# Reads the input from a forms file and splits it into parts.
$buffer = read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
$token = "";
@tokens = ( );
while ($buffer ne "")
{$c = chop($buffer);
if ($c eq "&" || $c eq "=")
{$tokens = push(@tokens, $token); $token = "";}
else
{$token = $c . $token;}
};
push(@tokens, $token);
@tokens = reverse(@tokens);
# Grabs name and email.
shift(@tokens);
$name = shift(@tokens);
shift(@tokens);
$email = shift(@tokens);
#__________________________HTML begins here
print <<END_OF_PART1;
Content-type: text/html
<HTML>
<HEAD>
<TITLE> Info</TITLE>
</HEAD>
<BODY>
<H1> Info</H1>
<HR>
<PRE>
END_OF_PART1
print "Name: $name <br>";
print "Email: $email <br>" ;
print <<END_OF_PART2;
</PRE>
<HR>
</BODY>
</HTML>
END_OF_PART2
print "";
in the input from two forms and print them on the screen. The preamble
seems to work fine - takes the input string and spilts it into the
component tokens. The print HTML bit does not work fine. What
appears on the browser
is:
Info
--------------------------------------------------------------------------------
Name:
Email:
with neither values of name or email displayed. Why is this?
A minor niggle - Perl does not seem to match END_OF_PART2 unless I
place the redundant print statement at the bottom. No idea why.
Mark
# Here is the Code
#!/usr/bin/perl
# Reads the input from a forms file and splits it into parts.
$buffer = read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
$token = "";
@tokens = ( );
while ($buffer ne "")
{$c = chop($buffer);
if ($c eq "&" || $c eq "=")
{$tokens = push(@tokens, $token); $token = "";}
else
{$token = $c . $token;}
};
push(@tokens, $token);
@tokens = reverse(@tokens);
# Grabs name and email.
shift(@tokens);
$name = shift(@tokens);
shift(@tokens);
$email = shift(@tokens);
#__________________________HTML begins here
print <<END_OF_PART1;
Content-type: text/html
<HTML>
<HEAD>
<TITLE> Info</TITLE>
</HEAD>
<BODY>
<H1> Info</H1>
<HR>
<PRE>
END_OF_PART1
print "Name: $name <br>";
print "Email: $email <br>" ;
print <<END_OF_PART2;
</PRE>
<HR>
</BODY>
</HTML>
END_OF_PART2
print "";