문제

I have a CGI script that serves up images using the File::Copy CPAN module:

use File::Copy;
.... (set appropriate content header)
binmode STDOUT;
copy $imageFile, \*STDOUT || die "Image delivery failed: $!";

This works fine under CGI but when run under mod_perl I get:

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

I'm not sure if this is expected behaviour or if there's a bug somewhere. I'm new to mod_perl and find I am drowning in a sea of documentation at the moment. Is there any way to change my script so it runs fine under CGI or mod_perl without changes?

도움이 되었습니까?

해결책

Not unless you're willing to change File::Copy or mod_perl (in negative ways). File::Copy expects a file handle associated with a system file handle, but STDOUT is a tied file handle.

다른 팁

From the mod_perl documentation

Under mod_perl, CORE::print( ) (using either STDOUT as a filehandle argument or no filehandle at all) will redirect output to Apache::print( ), since the STDOUT file handle is tied to Apache.

And from the BUGS section if perltie

Tied filehandles are still incomplete. sysopen(), truncate(), flock(), fcntl(), stat() and -X can't currently be trapped.

You can read more about this in the bug report at https://rt.perl.org/rt3//Public/Bug/Display.html?id=112164 if you wish.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top