Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello All,

I'm facing some strange issue with Perl CGI. I'm using Apache2 as the webserver (i also use mode_perl2).

The Problem is whenever i request the CGI URL (http://mydomai.com/cgi-bin/t2/detail.cgi?adId=9) , the page not properly refreshing or responding.
First time it reads the param and displays '9' then if i change the param value to 2 (or somthing else) it again displays 9 if i wait for sometime and hit the url it shows 2. again if the change the param value to 5 it displays 2 or 9...
basically the problem is CGI/apache stores the old value and display the same for a while or soemthing like that..
Any one please help to resolve this problem?

If i do CNTR+F5 it works properly..

I'm using the below CGI script. (Note: I also use startup.pl script to load some modules while apache start)
use CGI qw(:cgi-lib :standard); use CGI::Carp qw ( fatalsToBrowser ); use JSON::Parse 'parse_json'; use REST::Client; my $client = REST::Client->new(); $client->setHost('http://localhost'); my $query = new CGI(); $query->import_names('Q'); my $adId = $Q::adId; #my $adId = $query->param("adId"); print "Content-type: text/html\n\n"; print $adId;

Replies are listed 'Best First'.
Re: Perl CGI - Param value not refreshing (superfaq)
by Anonymous Monk on Feb 09, 2015 at 09:14 UTC

    I'm facing some strange issue with Perl CGI.

    Nothing really strange, just real basic pitfalls , like you've never read perlintro or coping with scoping or SYNOPSIS of CGI

    And then you throw mod_perl in the mix but you haven't read CGI to mod_perl Porting. mod_perl Coding guidelines

    You have a lot of reading to do so you can write

    #!/usr/bin/perl -- use strict; use warnings; use CGI qw(); use CGI::Carp qw ( fatalsToBrowser ); use JSON::Parse 'parse_json'; use REST::Client; Main( @ARGV ); exit( 0 ); sub Main { my $client = REST::Client->new(); $client->setHost('http://localhost'); my $q = CGI->new(); my $adId = $q->param('adId'); print $q->header, $adId; }