Any Perl CGI experts?

Status
Not open for further replies.

snapty00

Banned
Here's my relevant code, and here's the warning message that the script generates:

Use of uninitialized value in concatenation (.) or string at C:\ABG_kappaeta\mailer.pl line 19.

Code:
#! /usr/bin/perl

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

if ($ENV{'REQUEST_METHOD'} eq 'POST') {
	read(STDIN, my $buffer, $ENV{'CONTENT_LENGTH'});
	my @pairs = split(/&/,$buffer);

	foreach my $pair(@pairs) {
		(my $name, my $value) = split(/=/,$pair);
		$value =~ tr/+/ /;
		$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
		$FORM{$name} = $value;
	}
}


print <<ENDHTML;
<HTML>
<HEAD>
<TITLE>Mailer Thingy</TITLE>
</HEAD>
<BODY>
Name: $FORM{name} <br />
E-mail Address: $FORM{email} <br />
Graduation Year: $FORM{year} <br />
Doing Now: $FORM{doingnow} <br />
Comments: $FORM{comments} <br />
</BODY>
</HTML>

ENDHTML

# exit
exit();

The code actually works (it doesn't stall like a full-blown error), but I still get that warning. Why? Am I practicing a bad way of doing something that should really be done another way?

Thanks.
 
In other words, you mean that maybe some of them are blank? That's interesting, because when I test it in DOS, they're ALL blank. Maybe that's the problem. Should I test whether they're null or not, or do you think it's a warning not worth worrying about?
 
Blank isn't really an issue, unset is. If you want to get rid of the warning, you could preset the ones you actually intend to use to a blank string. It's probably not worth checking at the time for this, though, since you're obviously expecting a limited subset. So just make sure that subset is there. If something is optional, then you check if it's set or not before using it.
 
Status
Not open for further replies.
Top Bottom