Subject: | Non-existant CGI form fields vanish from sub parameter lists |
CGI V 3.05. The rt.cpan.org menu only goes up to 3.04 :-(.
This bug (as I believe it to be) has been around for years. I must apologize for not repoting it earlier. It only bites once every couple of years...
In the sample code, sub one receives 1 parameter, although called with 2.
CGI.pm is deleting the first parameter from the list because I deliberately refer to 'fake_name', a non-existant CGI form field, and CGI.pm does not in such a case return undef.
In the sample output, note specifically the comma after '2nd param', coming from the join, indicating that '2nd param' has been passed in as the first parameter.
Screen output:
-----><8-----
CGI.pm V 3.05
Old value: Param count: 1. Params: 2nd param, .
New value:
-----><8-----
Program:
-----><8-----
#!/usr/bin/perl
#
# Name:
# cgi-bug.cgi.
#
# Author:
# Ron Savage <ron@savage.net.au>
# http://savage.net.au/index.html.
use strict;
use warnings;
use CGI;
# -----------------
sub one
{
my($p1, $p2) = @_;
'Param count: ' . ($#_ + 1) . '. Params: '. join(', ', $p1, $p2) . '.';
} # End of one.
# -----------------
my($q) = CGI -> new();
print $q -> header({type => 'text/html;charset=ISO-8859-1'}),
$q -> start_html(),
$q -> start_form({action => $q -> url(), name => 'cgi_bug'}),
'CGI.pm V ', $CGI::VERSION,
$q -> br(),
'Old value: ' . one($q -> param('fake_name'), '2nd param'),
$q -> br(),
'New value: ' . $q -> textfield({name => 'real_name', size => 20}),
$q -> br(),
$q -> submit(),
$q -> end_form(),
$q -> end_html();
-----><8-----