Discipulus has asked for the wisdom of the Perl Monks concerning the following question:

hello wise monks,

I'm in a fix with an easy checkbox_group of the CGI.pm (2.81)on win32(perl -v This is perl, v5.8.0 built for MSWin32-x86-multi-thread)and running the cgi script on IIS 5.0 (all other CGI scripts works fine)

Now I'm starting a new script with a check box group: it seemed to me just easy.. and indeed I receive strange results:

1-with no check box checked it runs VERY slow and no results
2-with 1-3 box checked it works
3-with 4 or more checked the param seems not set..

any ideas ?

cheers from Roma Lor*
use CGI qw /:standard -nph/; $|++; $CGI::POST_MAX=100; $CGI::DISABLE_UPLOAD=1; my $q=new CGI; print header(); print start_html(-title=>'*check,-bgcolor=>"#000099",-text=>"#FF9933", +-link=>"#FF3300",-alink=>"#FF3300",-vlink=>"#FF3300"); my %labels=('200.160.128.41'=>'HOST01', '200.160.128.42'=>'HOST02', '200.160.128.52'=>'HOST03', '200.160.136.130'=>'HOST04', '200.160.136.131'=>'HOST05', '200.160.136.132'=>'HOST06', '200.160.136.133'=>'HOST07', '200.160.136.136'=>'HOST08', '200.160.136.139'=>'HOST09', '200.160.136.140'=>'HOST10', '200.160.128.31'=>'HOST11', '200.160.128.88'=>'HOST12', '200.160.136.135'=>'HOST-GEST', '200.160.128.62'=>'HOSTSsql04', '200.160.128.43'=>'HOSTsql03', ) ; print $q->start_form(-method=>'POST',-action=>url(-relative=>1),-name= +>'form1'); print $q->checkbox_group(-name=>'quale_server', -values=>['200.160.128.41', '200.160.128.42', '200.160.128.52', '200.160.136.130', '200.160.136.131', '200.160.136.132', '200.160.136.133', '200.160.136.136', '200.160.136.139', '200.160.136.140', '200.160.128.31', '200.160.128.88', '200.160.136.135', '200.160.128.62', '200.160.128.43'], #-default=>[keys %labels], -linebreak=>'true', #-size=>15, -multiple=>'true', -labels=>\%labels, #-columns=>2 ); print $q->submit(-value=>'search'),end_form(); print $q->br; if (defined $q->param()){print "The keywords are: ",em(join(", ",para +m('quale_server')))} ##or @server=param('quale_server'); ########################################################## print $q->end_html();


Update: it seems the madness was mine.. I never rialized well about not mixing object/function style (thnks Coltsfoot)
Tehn I putted everytime POSTMAX=100 but without thinking seriously about: I ever dealt with small posted data: now 3 IP are more then the max and checking print $q->cgi_error(); returns 413 Request entity too large like eieio suggested thnks

never start code at the end of a long week..

thnks Lor*

Replies are listed 'Best First'.
Re: checkbox_group CGI.pm madness
by ColtsFoot (Chaplain) on May 13, 2005 at 11:32 UTC
    Not quite sure what the question is but using strict and
    warnings is a good start. The following code now at least
    runs.
    You seem to be mixing the object/non-object method of calling the CGI functions
    #!/usr/bin/perl -w use strict; use CGI; use CGI::Carp qw(fatalsToBrowser); #$|++; # $CGI::POST_MAX=100; # $CGI::DISABLE_UPLOAD=1; my $q=new CGI; print $q->header(); print $q->start_html(-title=>'check',-bgcolor=>"#000099",-text=>"#FF99 +33", -link=>"#FF3300",-alink=>"#FF3300",-vlink=>"#FF3300"); my %labels=('200.160.128.41'=>'HOST01', '200.160.128.42'=>'HOST02', '200.160.128.52'=>'HOST03', '200.160.136.130'=>'HOST04', '200.160.136.131'=>'HOST05', '200.160.136.132'=>'HOST06', '200.160.136.133'=>'HOST07', '200.160.136.136'=>'HOST08', '200.160.136.139'=>'HOST09', '200.160.136.140'=>'HOST10', '200.160.128.31'=>'HOST11', '200.160.128.88'=>'HOST12', '200.160.136.135'=>'HOST-GEST', '200.160.128.62'=>'HOSTSsql04', '200.160.128.43'=>'HOSTsql03', ) ; print $q->start_form(-method=>'POST',-name=>'form1'); print $q->checkbox_group(-name=>'quale_server', -values=>['200.160.128.41', '200.160.128.42', '200.160.128.52', '200.160.136.130', '200.160.136.131', '200.160.136.132', '200.160.136.133', '200.160.136.136', '200.160.136.139', '200.160.136.140', '200.160.128.31', '200.160.128.88', '200.160.136.135', '200.160.128.62', '200.160.128.43'], #-default=>[keys %labels], -linebreak=>'true', #-size=>15, -multiple=>'true', -labels=>\%labels, #-columns=>2 ); print $q->submit(-value=>'search'),$q->end_form(); print $q->br; if (defined $q->param()){print "The keywords are: ",$q->em(join(", ", +$q->param('quale_server')))} ##or @server=param('quale_server'); ########################################################## print $q->end_html();
Re: checkbox_group CGI.pm madness
by eieio (Pilgrim) on May 13, 2005 at 12:50 UTC
    Setting $CGI::POST_MAX to 100 may be the reason why the parameter is not set with four or more check boxes checked. From CGI:
    $CGI::POST_MAX
    If set to a non-negative integer, this variable puts a ceiling on the size of POSTings, in bytes. If CGI.pm detects a POST that is greater than the ceiling, it will immediately exit with an error message. This value will affect both ordinary POSTs and multipart POSTs, meaning that it limits the maximum size of file uploads as well. You should set this to a reasonably high value, such as 1 megabyte.
    ...
    An attempt to send a POST larger than $POST_MAX bytes will cause *param()* to return an empty CGI parameter list. You can test for this event by checking *cgi_error()*, either after you create the CGI object or, if you are using the function-oriented interface, call <param()> for the first time. If the POST was intercepted, then cgi_error() will return the message "413 POST too large".