U
usenet
Greetings. Kindly consider this simplified CGI script which
illustrates my question:
#!/usr/bin/perl
use strict; use warnings;
use CGI qw{ :standard };
system('/var/www/cgi-bin/do_nothing.pl');
print(
header(),
start_html(),
start_form(),
h2(param('xxx')),
textfield({-name => 'xxx'}),
submit(),
end_form(),
end_html()
);
__END__
As you can see, the CGI first runs an external perl program. OK,
fine. Here is the external program:
#!/usr/bin/perl
use strict; use warnings;
use CGI qw{ header };
open (my $file, '>', '/tmp/junk.xxx') or die "oops - $!\n";
my $test_mode = 0;
print $file $test_mode ? header()
: "Content-Type: text/html;
charset=ISO-8859-1\n\n",
__END__
This external program simply prints an HTML content declaration to a
junk file. But it has the option to use CGI.pm's header() method, or
to just print hardcoded text. Either way, the resulting junk file is
identical (same md5sum).
When I run the CGI (in a browser), I should be able to type something
in the textbox and it will be shown to me when I click submit. And if
I run everything as posted, that's exactly what happens.
But if I change $test_mode to non-zero then the value of the CGI
parameter 'xxx' is no longer carried. I can type something in the
textfield and hit submit, but I won't see the value of the param.
Changing $test_mode back to zero causes the form to again work as
expected.
Somehow invoking the CGI.pm header method() in the external program is
causing my CGI form parameters to be lost between form invocations!
That's strange! Does anyone have any idea why?
Thanks!
illustrates my question:
#!/usr/bin/perl
use strict; use warnings;
use CGI qw{ :standard };
system('/var/www/cgi-bin/do_nothing.pl');
print(
header(),
start_html(),
start_form(),
h2(param('xxx')),
textfield({-name => 'xxx'}),
submit(),
end_form(),
end_html()
);
__END__
As you can see, the CGI first runs an external perl program. OK,
fine. Here is the external program:
#!/usr/bin/perl
use strict; use warnings;
use CGI qw{ header };
open (my $file, '>', '/tmp/junk.xxx') or die "oops - $!\n";
my $test_mode = 0;
print $file $test_mode ? header()
: "Content-Type: text/html;
charset=ISO-8859-1\n\n",
__END__
This external program simply prints an HTML content declaration to a
junk file. But it has the option to use CGI.pm's header() method, or
to just print hardcoded text. Either way, the resulting junk file is
identical (same md5sum).
When I run the CGI (in a browser), I should be able to type something
in the textbox and it will be shown to me when I click submit. And if
I run everything as posted, that's exactly what happens.
But if I change $test_mode to non-zero then the value of the CGI
parameter 'xxx' is no longer carried. I can type something in the
textfield and hit submit, but I won't see the value of the param.
Changing $test_mode back to zero causes the form to again work as
expected.
Somehow invoking the CGI.pm header method() in the external program is
causing my CGI form parameters to be lost between form invocations!
That's strange! Does anyone have any idea why?
Thanks!