I've always used this code to read in data from my forms, but for some reason it's not working. The server is still fine and is working with other Perl scripts, it's just this one. Can anyone see what is wrong with it?
#!/usr/bin/perl
use CGI qw
standard);
print header();
# Read in the form data
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
#$myKey = uc(trim($FORM{'Key'}));
$myKey = $FORM{'Key'};
print "Your Key $myKey\n";
#String to match
$keyMatch = "abc001";
if ($myKey eq $keyMatch)
{
# Send OK
print "This key is OK\n\n";
}
else
{
# Send Bad
print "This key is bad $myKey $keyMatch\n\n";
}
exit(0);
# Removes leading/trailing spaces
sub trim {
my @out = @_;
for (@out)
{
s/^\s+//;
s/\s+$//;
}
return wantarray ? @out : $out[0];
}
#!/usr/bin/perl
use CGI qw
print header();
# Read in the form data
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
#$myKey = uc(trim($FORM{'Key'}));
$myKey = $FORM{'Key'};
print "Your Key $myKey\n";
#String to match
$keyMatch = "abc001";
if ($myKey eq $keyMatch)
{
# Send OK
print "This key is OK\n\n";
}
else
{
# Send Bad
print "This key is bad $myKey $keyMatch\n\n";
}
exit(0);
# Removes leading/trailing spaces
sub trim {
my @out = @_;
for (@out)
{
s/^\s+//;
s/\s+$//;
}
return wantarray ? @out : $out[0];
}