Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl script not getting $ENV{'CONTENT_LENGTH'}

Status
Not open for further replies.

wsexton

Technical User
Dec 4, 2001
49
0
0
US
I have an html form that uses post
<form name="formname" method="post" action="cgi-bin/feedback.pl">

Here's the perl script:

#!/usr/bin/perl

use warnings;

use CGI;
use CGI::Carp qw(fatalsToBrowser);
use Mail::SendEasy;

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

my $FormData = "";

# Read the standard input (sent by the form):
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $FormData, $ENV{'CONTENT_LENGTH'});
# Get the name and value for each form input:
@pairs = split(/&/, $FormData);
# Then for each name/value pair....
foreach $pair (@pairs) {
# Separate the name and value:
($name, $value) = split(/=/, $pair);
# Convert + signs to spaces:
$value =~ tr/+/ /;
# Convert hex pairs (%HH) to ASCII characters:
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
# Store values in a hash called %FORM:
$FORM{$name} = $value;
}
}

my $name = $FORM{visitor};
my $email = $FORM{email};

I keep getting and unitialized value message for the read line. It appears that $ENV{'CONTENT_LENGTH'} is null.

Anyone have an idea what I might be doing wrong?

Thanks.

 
Look into using CGI.pm

but you should be passing keys in quotes to your $FORM{'variables'}

Code:
my $name = $FORM{'visitor'};
my $email = $FORM{'email'};

HTH
--Paul


Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top