[cgiapp] Re: Making the query string delimiter & instead of ;

Dave Baker davebaker at benefitslink.com
Tue Mar 10 16:04:41 EDT 2009


> Date: Tue, 10 Mar 2009 07:55:06 -0400 (EDT)
> From: "Jaldhar H. Vyas" <jaldhar at braincells.com>
> Subject: [cgiapp] Making the query string delimiter & instead of ;

> In order to acheive this I should do this in my subclass right?
> 
> sub cgiapp_get_query {
>      my ($self) = @_;
> 
>      # Include CGI.pm and related modules
>      require CGI;
>      CGI->import(qw/ -oldstyle_urls /);
> 
>      # Get the query object
>      my $q = CGI->new;
> 
>      return $q;
> }
> 
> But calling $query->self_url steadfastly gives me ; in my query strings. 
> What gives?

I think you need "use CGI qw ( -oldstyle_urls );"

This is working for me (the short instance script called test.cgi that 
runs CheckQuery.pm is not shown):

package CheckQuery;

use strict;
use base 'CGI::Application';

sub setup {
     my ( $self ) = shift;

     $self->run_modes(
         'view' => 'view_query_string' );

     $self->start_mode( 'view' );
}

sub view_query_string {
      my ( $self ) = shift;

      my $query = $self->query();

      $query->param( 'parameter1', 'value1' );
      $query->param( 'parameter2', 'value2' );

     return $query->self_url;
}

sub cgiapp_get_query {
     my ( $self ) = shift;

     use CGI qw( -oldstyle_urls );
     my $q = CGI->new();

     return $q;
}

1;

-- 

Output is
http://192.168.1.100/cgi-bin/test.cgi?parameter1=value1&parameter2=value2

--

Make sure you don't try using "my $q = self->query();" instead of "my $q 
= CGI->new()" on your production server, or you'll use all your server's 
CPU while the hard drive thrashes until the server eventually runs out 
of memory and cannot even be accessed from a terminal, such that calling 
support to have your server rebooted during your peak business hours is 
your only option.

(From one knows, haw)

10 Dave Baker
GOTO 10


More information about the cgiapp mailing list