使用file::copy在mod_perl下提供图像失败
我有一个CGI脚本,它使用File::Copy CPAN模块提供图像:使用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
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 如果您愿意,您可以在错误报告中阅读更多关于此的内容