开发者

Perl CGI script returns different results depending on run

开发者 https://www.devze.com 2023-01-05 19:02 出处:网络
I have a Perl CGI script that emits different HTML apparently randomly. None of the inputs change. E.g., I will run wget twice and get two different results. The CGI is backed by a development databas

I have a Perl CGI script that emits different HTML apparently randomly. None of the inputs change. E.g., I will run wget twice and get two different results. The CGI is backed by a development database that, too, doesn't change.

I have a debug statement that informs me that the same number of elements are returned from th开发者_高级运维e DB into the script.

Frankly, I'm mystified. Logic, DB, and inputs don't change, but the output does.

The http server is apache2 on Ubuntu 10.04. Perl version is perl 5.10.

edit: whenever I run it from the command-line on the server, the output is correct.

edit2: some of the bad runs seem like prior versions of the script. I don't think Apache is caches CGIs, but it seems like it might be grabbing out-of-date cache versions....


Is your CGI script being run using Apache's standard CGI API or are you running it under mod_perl using the Apache::Registry (or ModPerl::Registry in Apache2) CGI emulation layer?

I have seen an effect similar to the one you describe, which results from the way mod_perl's CGI emulation works. The details are discussed here.

One workaround is to take any 'global' variables declared at the start of the script with 'my' and change the keyword 'my' to 'our'.

Of course your problem may be something completely different - it's very hard to say without more information.


Caching: Apache probably isn't caching, but your browser may be. Turn off caching (set your browser cache to 0MB).

Command line: If your output differs from webpage to CLI execution of the script, then it seems like either you're missing header information, or the HTML tags are not complete or broken. For example, you need the Content-Type statement with two newlines after.

If it works on CLI but now through CGI on the webserver, it has to be your code, a missing module in Apache, or something like that.

0

精彩评论

暂无评论...
验证码 换一张
取 消