的Perl CGI脚本根据运行返回不同的结果 [英] Perl CGI script returns different results depending on run

查看:238
本文介绍了的Perl CGI脚本根据运行返回不同的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有不同的发射显然HTML随机一个Perl CGI脚本。无输入变化。例如,我将运行的wget 两次,得到两个不同的结果。该CGI是由一个开发数据库,​​也不会改变支持。

我有告诉我,相同数量的元素都是从DB返回到脚本调试语句。

坦率地说,我大惑不解。逻辑,DB和投入不改变,但输出一样。

HTTP服务器是在Ubuntu 10.04的Apache2。 Perl版本是Perl 5.10的。

编辑:每当我从服务器上的命令行运行它时,输出是正确的。

EDIT2:一些坏奔跑看起来像脚本的早期版本。我不的认为的Apache是​​缓存的CGI,但似乎它可能是抓住了过期缓存版本....


解决方案

是您的CGI脚本正在运行使用Apache的标准的CGI API或者你使用Apache ::注册mod_perl下运行它(或ModPerl ::注册处的Apache2) CGI模拟层?

我看到一个类似于你描述,它从mod_perl的的方式CGI模拟工作结果产生影响。细节这里讨论。<​​/ P>

一个解决办法是采取申报的全局变量在与'我的'脚本的开始,改变关键字'我'为'我们'。

当然,你的问题可能是一些完全不同 - 这是很辛苦没有更多的信息说

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 the 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.

这篇关于的Perl CGI脚本根据运行返回不同的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆