Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

CGI dropping my params

by Jonathan (Curate)
on Feb 08, 2001 at 20:26 UTC ( [id://57201]=perlquestion: print w/replies, xml ) Need Help??

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

I'm still struggling with Apache::Registry/CGI
One particular script calls another passing a list of parameters that the user selected. The second script (using the wonderful Spreadsheet::WriteExcel module) sends back a spreadsheet to the users browser. This works fine. In fact better than we'd hoped.
However, there is one annoying problem. If you press 'Back' and then re-run every 'n' number of times the parameters seem to get lost. For example the code snippet
for ($q->param(-name=> 'Country')) { $redr .= "&COUNTRY=$all_countries{$_}"; }
Normally correctly generates something like the following

country_report.pl?COUNTRY=AF&COUNTRY=UAJ&COUNTRY=AL&COU NTRY=DZ&COUNTRY=AD
But sometimes this appears

country_report.pl?COUNTRY=&COUNTRY=&COUNTRY=&COUNTRY =&COUNTRY=&COUNTRY=&COUNTRY=&COUNTRY=

Before you ask use strict and warnings are on, The Apache error_log doesn't mention anything. The script saves and loads the current parameters in a file. By the way, I've pulled all my hair out. Any ideas gratefully received.

Replies are listed 'Best First'.
Re: CGI dropping my params
by merlyn (Sage) on Feb 08, 2001 at 20:45 UTC
    If it happens every "N number of times", that means one of the proceses has some stale data (something wasn't cleaned out completely on a previous invocation). Make sure you're not falling into any of the traps of Apache::Registry by reading the excellent mod_perl handbook at the site.

    -- Randal L. Schwartz, Perl hacker

      Thanks merlyn - I've spent the last few days re-writing code to cater for the various Apache::Registry gotcha's and managed to convince myself that this was another one.

      But 5 minutes ago I realised it was just me being stupid - I had an empty hash, the code normally works because of the persistence that is provided but it wasn't explicity initialised in the section of the code dealing with these requests.

      Sincere apologies

      Jonathan
      /me wanders off feeling more stupid than usual
Re: CGI dropping my params
by dws (Chancellor) on Feb 09, 2001 at 07:07 UTC
    'Country' ne 'COUNTRY'

    Any chance of that being a factor? Without seeing more of your code, it's hard to tell, but I've been bitten by case-dependent strings comparisons more than a few times.

      No 'COUNTRY' is just a literal required by the next routine. The problem was with the %all_countries hash not being populated sometimes. Thank anyway.

      And now I lay me down to sleep
      I pray the NodeReaper my Node to keep

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://57201]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2024-04-24 23:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found