cormanaz has asked for the wisdom of the Perl Monks concerning the following question:
and here is the test.htm it uses#!/usr/bin/perl -w use strict; use HTTP::Daemon; use CGI qw/:standard/; my $d = HTTP::Daemon->new(LocalPort => 8080) || die; while (my $c = $d->accept) { while (my $r = $c->get_request) { my $uri = $r->uri; $ENV{REQUEST_METHOD} = $r->method; $ENV{CONTENT_TYPE} = join('; ', $r->content_type) || ''; $ENV{CONTENT_LENGTH} = $r->content_length || ''; $ENV{SCRIPT_NAME} = $uri->path || 1; $ENV{QUERY_STRING} = $uri->query || ''; my $q = new CGI; my $reply; my $scriptname = $ENV{'SCRIPT_NAME'}; #$q = new CGI; if ($scriptname =~ /start/) { $reply = $q->header; open(IN,"test.htm") or die "Can't open input: $!\n"; while(<IN>) { $reply .= $_; } close IN; } elsif ($scriptname eq '/process') { my @params = $q->param; $reply = $q->header; $reply .= $q->start_html.$q->h2("Parameters").join('<br>', +@params).$q->end_html; } $c->send_response($reply); } $c->close; undef($c); }
I get the initial page with localhost:8080/start. Upon clicking SUBMIT I get error Use of uninitialized value in pattern match (m//) at (eval 22)[C:/Perl/site/lib/CGI.pm:829] line 4.. If I step through the code with the (Komodo) debugger, it goes into an infinite wait at my $q = new CGI;. I found that if I delete the enctype argument from the form tag in the htm file, I get no error and the infinite wait, debugger or no.<html> <body> <form method="post" action="process" enctype="multipart/form-data"> <input type="checkbox" name="cb" value="on" /><input type="text" name= +"label" value="foobar" size="40" /> <input type="submit" name=".submit" /> </form> </body> </html>
I found this thread that seems to discuss a similar problem, but it's talking about file uploads and anyway is four years old so I would think that this particular bug has been worked out by now.
Anyone know what the problem is here?
Thx...Steve
Edit: g0n - corrected link format
Update: In the code above I commented out the second CGI constructor, a mistake caught by Chromatic. But that didn't fix the problem. Also based on his opinion that CGI didn't have the proper filehandle, and the old thread linked above, I tried inserting local *main::STDIN = $c; right before the CGI constructor, and that didn't fix things either.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Mod CGI problems with POST
by chromatic (Archbishop) on May 31, 2007 at 00:33 UTC | |
by cormanaz (Deacon) on May 31, 2007 at 01:20 UTC | |
by chromatic (Archbishop) on May 31, 2007 at 06:07 UTC | |
by cormanaz (Deacon) on May 31, 2007 at 14:45 UTC | |
by chromatic (Archbishop) on May 31, 2007 at 18:10 UTC | |
|
Re: Mod CGI problems with POST
by derby (Abbot) on May 30, 2007 at 23:54 UTC | |
by cormanaz (Deacon) on May 31, 2007 at 01:19 UTC | |
|
Re: Mod CGI problems with POST
by stonecolddevin (Parson) on May 30, 2007 at 22:36 UTC |