@array has no value from cgi.pm STDIN

  • Thread starter Robert Valcourt
  • Start date
R

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<br>";
}

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:

<form method="post" action="request-quote.pl">
<input type="checkbox" name="service" value="Outdoor Recreation">
<input type="checkbox" name="service" value="Education Programming">
<input type="checkbox" name="service" value="Retreat">
<input type="checkbox" name="service" value="Accommodations">
</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....read/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
 
A

A. Sinan Unur

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<br>";
}

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top