zigdon has asked for the wisdom of the Perl Monks concerning the following question:
It accepts a single parameter (theme), and returns an unordered list of similar themes (used in an AJAX autocomplete setup). When I run it under normal perl, everything works great:#!/usr/bin/speedy -wT use strict; use CGI::Simple; use MyApp::Theme; + + use vars qw/$q/; + + $q = new CGI::Simple; + + warn $q->Dump; + + if ($q->param('theme') =~ m#([\w\-:(){} /]+)#) { my $theme = $1; + + my @themes = map {$_->theme} MyApp::Theme->search_like(theme => $the +me."%"); my %matches; + + foreach (@themes) { my $nextslash = index($_, " / ", length $theme); if ($nextslash == -1) { # not found - it's a leaf $matches{$_} = $_; } elsif (not exists $matches{$_}) { substr($_, $nextslash) = ""; $matches{$_} = "$_ / "; } } + + print $q->header; print "<ul>"; foreach (sort keys %matches) { print "<li>$_</li>"; } unless (exists $matches{$theme}) { print "<li>$theme</li>"; } print "</ul>"; }
When I switch to speedy, I get this:$VAR1 = bless( { '.parameters' => [ 'theme', '_' ], '.globals' => { 'DEBUG' => '0', 'NO_UNDEF_PARAMS' => '0', 'NO_NULL' => 1, 'FATAL' => -1, 'USE_PARAM_SEMICOLONS' => '0', 'DISABLE_UPLOADS' => 1, 'USE_CGI_PM_DEFAULTS' => '0', 'NPH' => '0', 'POST_MAX' => 102400, 'HEADERS_ONCE' => '0' }, '.fieldnames' => { '_' => 1, 'theme' => 1 }, '_' => [ '' ], 'theme' => [ 'Some value' ] }, 'CGI::Simple' ); at /var/www/cgi-bin/ac_theme line 16.
What gives? Update: Just occured to me to switch to the regular CGI, and sure enough, everything works again, even under speedy. I guess CGI::Simple isn't doing something right?$VAR1 = bless( { '.globals' => { 'DEBUG' => '0', 'NO_UNDEF_PARAMS' => '0', 'NO_NULL' => 1, 'FATAL' => -1, 'USE_PARAM_SEMICOLONS' => '0', 'DISABLE_UPLOADS' => 1, 'USE_CGI_PM_DEFAULTS' => '0', 'NPH' => '0', 'POST_MAX' => 102400, 'HEADERS_ONCE' => '0' }, '.cgi_error' => '500 Bad read on POST! wanted 48, go +t 0' }, 'CGI::Simple' ); at /var/www/cgi-bin/ac_theme line 16.
-- zigdon
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: SpeedyCGI and POSTs using CGI::Simple
by PodMaster (Abbot) on Sep 30, 2005 at 00:33 UTC |