At 11:21 PM 08/21/02 +0800, Connie Chan wrote:
>This works for me =)
"works" in some measure of the word, yes.
>#!Perl
no -w
>use strict;
>use CGI::Carp (fatalsToBrowser);
>$| = 1;
^^^^^^^^
Why non-buffered?
>
>my $filepath = 'some/where/the/file/is.jpg";
syntax error.
>open IMG, "$filepath" or die "$!";
why the quotes?
>print "Content-type: image/jpeg\r\n\r\n";
\r\n\r\n is not needed.
>binmode (IMG); binmode (STDOUT);
>print while (<IMG>);
Why print a binary file "line-by-line"?
Try this modification and look at your log file:
my $x;
while ( <IMAGE> ) {
printf( STDERR "Chunk %d %d bytes.\n", ++$x, length );
print;
}
For a 40K jpeg I get 140 writes. Using read() it writes in three chunks.
Your code is telling perl to flush after every print, and then it goes on
to make a whole bunch of prints since you are treating the binary file like
a text file.
--
Bill Moseley
mailto:[EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]