Basic help for the Perl CGI module

I want to use the Perl CGI module to create CGI scripts. I looked through the available documentation here , but I seem to have missed something obvious, because I have run into problems with my first program. Here is the HTML:

<form name="form1" method="post" action="http://localhost/cgi-bin/filters.cgi">
<input name="mainbox" type="checkbox"> Mainbox<br> <br>
<input name="n1" type="checkbox">No. 1 <br><br>
<input name="n2" type="checkbox"> No. 2<br><br>
<input name="n3" type="checkbox">No. 3 <br>
<div style="text-align: center;"><input name="Submit" value="Submit" type="submit"></div>
</form>

I just want the parameter names that were passed to the CGI file to be printed on a new page. So, (with my limited understanding), I wrote the following in filters.cgi:

#!/xampp/perl/bin/perl -w
use strict;
use warnings;
use CGI;

my $query = CGI->new;
print $query = $query->header('text/html');
my @names = $query->param;

my $q1 = CGI->new;
print $q1->header('text/html');
print $q1->start_html('hello');
foreach my $name (@names) {
    print $q1->h1($name);
}
print $q1->end_html;

But it does not betray anything. It also gives me no error, and the syntax is fine. I know that I am missing something very simple here, but I really want to help with this. How do I write this script correctly? I use XAMPP on Windows XP, if that matters.

EDIT: , , . script, :

#!/usr/bin/perl
use strict;
use warnings;
use CGI;

my @arr = ('ac', 'fg', 'ty');
my $q1 = CGI->new;
print $q1->header('text/html');
$q1->start_html('hello world');
foreach my $el (@arr) {
    print $q1->p($el);
}
$q1->end_html;

, - . , , . , Nikhil . , , , script . ?

+3
2

, $query->header('text/html') $query, , , my @names = $query->param .

-, Content-type, $query CGI $q1.

CGI, $q1 $query .

.

#!/xampp/perl/bin/perl -w
use strict;
use warnings;
use CGI;

my $query = CGI->new;
my @names = $query->param;

print $query->header('text/html');
print $query->start_html('hello');

foreach my $name (@names) {
    print $query->h1($name);
}

print $query->end_html;
+4
print $query = $query->header('text/html');

. $query->header() , $query to. CGI ($query $q1), , . , .

+2

All Articles