in reply to Re: How to send a file vith apache?
in thread How to send a file vith apache?

That works, but I don't like the use of the <> diamond operator to deal with binary files. If there aren't any newline characters in the file, you'll read it all in one go; if there are many of them you'll read a line and print it many times.

I think it's better to use the simple read function for this:

while (read(INP,$buf,8192)) { print $buf; }

Much more predictable behavior.

Replies are listed 'Best First'.
Re: Re: Re: How to send a file vith apache?
by matija (Priest) on May 01, 2004 at 17:36 UTC
    Well, if you use sysread, you should also use syswrite instead of print. That way you don't have to bother with binmode, etc. And somehow, it seems cleaner to me than mixing the two different idioms.

      I didn't use sysread, just read, which uses buffering the same way as the diamond operator. It just reads a fixed number of bytes instead of scanning for EOL.

      You're right that sysread and syswrite would work fine; they might even be a little faster.