I am running Linux 2.2, Apache 1.3.12, mod_perl 1.24, and CGI.pm 2.70.
If I declare a CGI variable using 'my' (see below) and use mod_perl, I
encounter problems with POST data. On subsequent entries in the form,
it continues to use the old data.
The problem does not appear if I don't use 'my' (and therefore, unable
to 'use strict'), or if I disable mod_perl from my httpd.conf file.
You can test this out with these files. First, run 'httpd -X'. Then
enter some data in the form. On the next submit, the data is not
changed.
Note: The perl script displays the current HTML file plus what you
just entered.
htdocs/form.html
----------------
<html>
<head></head>
<body>
<form actioN="/cgi-bin/form.pl" method="post">
Name:
<input type="text" name="Name" value="">
<input type="submit">
</form>
<!--ARGS-->
</body>
</html>
cgi-bin/form.pl
---------------
#!/usr/local/bin/perl -w
# Problem if declaring $query with 'my' and using
# Apache 1.3.12, mod_perl 1.24, CGI.pm 2.70
use CGI;
my $query = new CGI;
print "Content-Type: text/html\n\n";
open(FD, "../htdocs/form.html") || die $!;
while (<FD>) {
if (/^<!--ARGS-->$/) {
printQueryParams();
}
else { print; }
}
close(FD);
sub printQueryParams
{
my @params = $query->param();
my ($arg, $val);
foreach $arg (@params) {
$val = $query->param($arg);
print "$arg = $val<BR>\n";
}
}
-Steven