1

我正在尝试在 IIS 下运行一些 Perl CGI 脚本。我收到以下消息:


CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LC_ALL = (unset),
    LANG = (unset)
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

我发现只有当我“使用”我们的内部库时才会出现问题,但它确实是一个很大的库(使用许多其他东西),所以我更愿意知道在哪里看。当我从命令行运行相同的脚本时,脚本运行得很好。我尝试将“LANG”设置为“C”,然后将“LC_ALL”设置为“C”,但没有效果。

欢迎任何指点!

4

4 回答 4

2

The LANG and LC_ALL environment variables are set for your shell, but they aren't set for IIS. I'm not an IIS person, but the docs say that IIS is a service and you have to set those ahead of time then reboot.

Alternatively, you can set these variables as soon your script starts to compile (and before you load your large library that is causing the problems:

BEGIN {
 $ENV{LC_ALL} = ...;
 $ENV{LANG} = ...;
 }

Get the values that you should use by looking at the ones you have in your shell.

Good luck,

于 2008-12-08T17:22:46.947 回答
0

似乎您的 Perl 应用程序正在将其错误发送到浏览器,并且在发送标头之前发生错误。

如果您使用的是 CGI 模块,则第一个可能是由use CGI::CARP qw(fatalsToBrowser).

在这种情况下fatalsToBrowser,弊大于利,所以我建议您暂时将其关闭。

于 2008-12-08T17:00:23.623 回答
0

The perldoc for locale might help you. It even features a troubleshooting section.

于 2008-12-08T17:17:18.877 回答
0

You can suppress this error by setting PERL_BADLANG=0, though that, like LC_ALL, needs to be set before your Perl script runs.

于 2008-12-08T17:21:28.200 回答