@array has no value from cgi.pm STDIN

@array has no value from cgi.pm STDIN

am 06.11.2007 21:54:24 von Robert Valcourt

Greetings,

I have a Website form with 4 checkboxes each with the same name but
different values. I use cgi.pm to build an @array from these values but it
doesn't seem to be working. The script:

#!/usr/bin/perl
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use strict;

my @services = param('service');

foreach my $choice (@services) {
$choice = "$choice
";
}

print "Content-type: text/html \n\n";
print @services;
exit;

The result is an empty page. The page should have up to 4 lines of text with
the values of the checkboxes as seen below.

Here is what is odd, I use this same exact script for another website that
is on the same server, accesses the same perl library and it works just
fine. The only difference if the site that works has a doctype of 4.01
transitional and is .html and the one that doesn't work doctype xhtml 1.0
and is .php. I wonder if this is an issue. The form:








I "could" name each of the checkboxes different but i'd like to make this
work if possible as does my other script. For what it is worth I have also
tried:

use CGI;
my $q = new CGI;
my @services = $q->param('service');

As described from post:
http://groups.google.ca/group/comp.lang.perl.misc/browse_thr ead/thread/c6fdb07ada986311/75482491e9e6a6fa

CGI.pm is supposed to handle this right? I'm really scratching my head on
this one and its starting to hurt.

TIA

Robert

Re: @array has no value from cgi.pm STDIN

am 06.11.2007 22:05:56 von 1usa

"Robert Valcourt" wrote in
news:4w4Yi.184258$1y4.103141@pd7urf2no:

> I have a Website form with 4 checkboxes each with the same name but
> different values. I use cgi.pm to build an @array from these values

I don't know what cgi.pm is. However, there is a CGI.pm module. Case
matters.

> but it doesn't seem to be working. The script:
>
> #!/usr/bin/perl
> use CGI qw(:standard);
> use CGI::Carp qw(fatalsToBrowser);
> use strict;

use warnings;

> my @services = param('service');
>
> foreach my $choice (@services) {
> $choice = "$choice
";
> }
>
> print "Content-type: text/html \n\n";
> print @services;

You are lying about the content.

....

> works just fine. The only difference if the site that works has a
> doctype of 4.01 transitional and is .html and the one that doesn't
> work doctype xhtml 1.0 and is .php. I wonder if this is an issue. The

So, you are moving from a loosy-goosy doctype to a strict one and you
wonder why the strict doctype does not work when you don't conform to
its, ahem, strict requirements?

Try the following:

#!/usr/bin/perl

use strict;
use warnings;

use CGI; # qw( -debug ) # for testing using the command line

my $cgi = CGI->new;
my @services = $cgi->param('service');

print $cgi->start_html(),
$cgi->ul( $cgi->li( \@services ) ),
$cgi->end_html();

__END__

Sinan

--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
clpmisc guidelines: