You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "Alexei V. Barantsev" <ba...@kazbek.ispras.ru> on 2000/08/29 14:11:39 UTC
CGI.pm problem
Dear mod_perl'ers!
I have found strange difference between object and func modes of CGI
library. More precisely - I have a problem with Vars function.
Let me show an example:
#!/usr/bin/perl -w
use Data::Dumper;
use CGI;
my $q = new CGI;
my $args = $q->Vars;
#use CGI qw(:standard :cgi-lib);
#my $args = Vars;
print
header,
start_html,
p( Dumper( $args ) ),
start_form( -method => "POST", -action => "/~barancev/cgi-perl/test.pl" ),
textfield( -name => "name", -size => 50 ),
submit( -name => "submit", -value => "Submit" ), submit( -name => "cancel", -value => "Cancel" ),
end_form,
end_html;
All works ok, when I click button I see what button was pressed and
what string was entered.
But if I try functional way instead (commented in example) I see that
$args is empty! In single-process mode (httpd -X) both examples work
right. Why?
(BTW, both examples was tried on clean, just started Apache)
--
ab
ICQ: 3959207
Re: CGI.pm problem
Posted by "Alexei V. Barantsev" <ba...@kazbek.ispras.ru>.
Rick Myers <ri...@sumthin.nu> writes:
> On Aug 29, 2000 at 16:11:39 +0400, Alexei V. Barantsev twiddled the keys to say:
> > Dear mod_perl'ers!
> >
> > I have found strange difference between object and func modes of CGI
> > library. More precisely - I have a problem with Vars function.
> >
> > #use CGI qw(:standard :cgi-lib);
>
> CGI::_reset_globals;
>
> > #my $args = Vars;
>
> _reset_globals() is normally called when you create a new CGI object.
> In this context though, your object lives on between script runs so you
> have to manually tell CGI to reset it.
O-o-ps!
Isn't it a good idea to put this tip into documentation - mod_perl
traps with functional mode of CGI.pm?
--
ab
ICQ: 3959207
Re: CGI.pm problem
Posted by Rick Myers <ri...@sumthin.nu>.
On Aug 29, 2000 at 16:11:39 +0400, Alexei V. Barantsev twiddled the keys to say:
> Dear mod_perl'ers!
>
> I have found strange difference between object and func modes of CGI
> library. More precisely - I have a problem with Vars function.
>
> #use CGI qw(:standard :cgi-lib);
CGI::_reset_globals;
> #my $args = Vars;
_reset_globals() is normally called when you create a new CGI object.
In this context though, your object lives on between script runs so you
have to manually tell CGI to reset it.
Rick Myers rik@sumthin.nu
----------------------------------------------------
The Feynman Problem 1) Write down the problem.
Solving Algorithm 2) Think real hard.
3) Write down the answer.
Re: Migrating from CGI.pm to (...?), was Re: CGI.pm problem
Posted by Jeff Beard <je...@cyberxape.com>.
Ah, so there is. I grep'd an older version which didn't since I'd never
heard of it before.
You use Apache::Request to get query parameters the same way you do with
CGI.pm's param() method. perldoc Apache::Request.
Did you could try just importing the CGI.pm HTML functions?
Personally, I prefer Template Toolkit for HTML generation. There are other
templating systems too. Search the archives for discussions on the subject.
Or as Stas suggested, check out the version 3 beta. I've been using it on
my personal web server for a few months with no problems, though I don't
use any of the HTML generation features.
--Jeff
At 10:32 AM 8/30/00 +0400, Alexei V. Barantsev wrote:
>Jeff Beard <je...@cyberxape.com> writes:
>
> > There isn't a Vars() function in CGI.pm. If you're looking for the query
> > string try param(). Or if you want to make it a mod_perl program (which is
> > what you would normally discuss on this list) Apache::Request::param().
> >
> > --Jeff
>
>There is such a function, Jeff!
>
>Well, could you advice, how to migrate from CGI.pm to Apache or
>Apache::Request. The matter is that I have used CGI.pm for HTML
>generation primarily and ready to use something another to analyze
>request parameters. But I cannot use CGI and e.g Apache::Request
>simultaneousely - server hangs. Is there some CGI.pm replacement
>intended only for HTML generation in the same manner (which does
>nothing with request, especially POST request)?
>
>--
>ab
>ICQ: 3959207
Jeff Beard
__________________________________
Web: www.cyberxape.com
Email: jeff at cyberxape dot com
Location: Boulder, Colorado, USA
Re: Migrating from CGI.pm to (...?), was Re: CGI.pm problem
Posted by Stas Bekman <st...@stason.org>.
On 30 Aug 2000, Alexei V. Barantsev wrote:
> Jeff Beard <je...@cyberxape.com> writes:
>
> > There isn't a Vars() function in CGI.pm. If you're looking for the query
> > string try param(). Or if you want to make it a mod_perl program (which is
> > what you would normally discuss on this list) Apache::Request::param().
> >
> > --Jeff
>
> There is such a function, Jeff!
>
> Well, could you advice, how to migrate from CGI.pm to Apache or
> Apache::Request. The matter is that I have used CGI.pm for HTML
> generation primarily and ready to use something another to analyze
> request parameters. But I cannot use CGI and e.g Apache::Request
> simultaneousely - server hangs. Is there some CGI.pm replacement
> intended only for HTML generation in the same manner (which does
> nothing with request, especially POST request)?
CGI.pm 3.x is supposed to have the args processing and html generation
separated. See:
http://stein.cshl.org/WWW/software/CGI/cgi_docs.html
http://stein.cshl.org/WWW/software/CGI/CGI.pm-3.01.tar.gz (beta)
_____________________________________________________________________
Stas Bekman JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide http://perl.apache.org/guide
mailto:stas@stason.org http://apachetoday.com http://jazzvalley.com
http://singlesheaven.com http://perlmonth.com perl.org apache.org
Migrating from CGI.pm to (...?), was Re: CGI.pm problem
Posted by "Alexei V. Barantsev" <ba...@kazbek.ispras.ru>.
Jeff Beard <je...@cyberxape.com> writes:
> There isn't a Vars() function in CGI.pm. If you're looking for the query
> string try param(). Or if you want to make it a mod_perl program (which is
> what you would normally discuss on this list) Apache::Request::param().
>
> --Jeff
There is such a function, Jeff!
Well, could you advice, how to migrate from CGI.pm to Apache or
Apache::Request. The matter is that I have used CGI.pm for HTML
generation primarily and ready to use something another to analyze
request parameters. But I cannot use CGI and e.g Apache::Request
simultaneousely - server hangs. Is there some CGI.pm replacement
intended only for HTML generation in the same manner (which does
nothing with request, especially POST request)?
--
ab
ICQ: 3959207
Re: CGI.pm problem
Posted by Jeff Beard <je...@cyberxape.com>.
There isn't a Vars() function in CGI.pm. If you're looking for the query
string try param(). Or if you want to make it a mod_perl program (which is
what you would normally discuss on this list) Apache::Request::param().
--Jeff
At 04:11 PM 8/29/00 +0400, Alexei V. Barantsev wrote:
> Dear mod_perl'ers!
>
>I have found strange difference between object and func modes of CGI
>library. More precisely - I have a problem with Vars function.
>
>Let me show an example:
>
>#!/usr/bin/perl -w
>
>use Data::Dumper;
>
>use CGI;
>my $q = new CGI;
>my $args = $q->Vars;
>#use CGI qw(:standard :cgi-lib);
>#my $args = Vars;
>
>print
> header,
> start_html,
> p( Dumper( $args ) ),
> start_form( -method => "POST", -action => "/~barancev/cgi-perl/test.pl" ),
> textfield( -name => "name", -size => 50 ),
> submit( -name => "submit", -value => "Submit" ), submit( -name =>
> "cancel", -value => "Cancel" ),
> end_form,
> end_html;
>
>All works ok, when I click button I see what button was pressed and
>what string was entered.
>
>But if I try functional way instead (commented in example) I see that
>$args is empty! In single-process mode (httpd -X) both examples work
>right. Why?
>
>(BTW, both examples was tried on clean, just started Apache)
>
>--
>ab
>ICQ: 3959207
Jeff Beard
__________________________________
Web: www.cyberxape.com
Email: jeff at cyberxape dot com
Location: Boulder, Colorado, USA