Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用file::copy在mod_perl下提供图像失败_Perl_Cgi_Mod Perl_Mod Perl2 - Fatal编程技术网

使用file::copy在mod_perl下提供图像失败

使用file::copy在mod_perl下提供图像失败,perl,cgi,mod-perl,mod-perl2,Perl,Cgi,Mod Perl,Mod Perl2,我有一个CGI脚本,它使用File::Copy CPAN模块提供图像: use File::Copy; .... (set appropriate content header) binmode STDOUT; copy $imageFile, \*STDOUT || die "Image delivery failed: $!"; 这在CGI下运行良好,但在mod_perl下运行时,我得到: [File::Copy::copy 140] stat() on unopened filehan

我有一个CGI脚本,它使用File::Copy CPAN模块提供图像:

use File::Copy;
.... (set appropriate content header)
binmode STDOUT;
copy $imageFile, \*STDOUT || die "Image delivery failed: $!";
这在CGI下运行良好,但在mod_perl下运行时,我得到:

[File::Copy::copy 140]  stat() on unopened filehandle STDOUT at /usr/share/perl/5.14/File/Copy.pm line 140.

我不确定这是否是预期的行为,或者某个地方是否有bug。我是mod_perl新手,现在发现自己正淹没在文档的海洋中。是否有任何方法可以更改我的脚本,使其在CGI或mod_perl下正常运行而不进行任何更改?

除非您愿意更改File::Copy或mod_perl(以负面方式)。文件::复制需要一个与系统文件句柄关联的文件句柄,但STDOUT是一个绑定的文件句柄。

来自mod_perl文档

在mod_perl下,CORE::print()(使用STDOUT作为filehandle参数或根本不使用filehandle)将把输出重定向到Apache::print(),因为STDOUT文件句柄与Apache绑定

如果可能的话,从BUGS部分

绑定的文件句柄仍然不完整。当前无法捕获sysopen()、truncate()、flock()、fcntl()、stat()和-X

如果您愿意,您可以在错误报告中阅读更多关于此的内容