On Thursday 20 June 2002 4:34 pm, David T-G wrote:
> Gary --
>
> ...and then Gary Stainburn said...
> %
> % On Thursday 20 June 2002 3:56 pm, Gary Stainburn wrote:
> % >
> ...
> % > What's the best way to cat a binary (file with non-display chars) to
> % > STDOUT?
> ...
> % open(FIN,"<$fname.pdf") || &dodie("cannot access PDF: $!\n";
> % print "Content-Type: text/html\n\n";
> % while (sysread FIN, $buffer, 4096) {
> % print $buffer);
> % }
> % close FIN;
>
> I haven't tested this, and you probably have and have found it lacking,
> but you don't mention it twice... Have you tried just printing the
> filehandle without anything special? I should think that if you
>
> ...
> open (FIN, "<$fname.pdf") ...
> ...
> while(<FIN>) {print};
> close FIN;
Hi David,
I could have done that, and with a purely text file I would have.
However, with binary files there can be a hell of a lot of characters between
the newlines. This way, the largest block read will be 4K.
Also, if there are lots of short lines, this way will be more efficiet.
>
> then it would suck it in and spit it out. You could probably even reset
> some punctuation vars and squirt through the whole thing in one pass
> rather than stopping on any newlines you might happen to find...
>
>
> HTH & HAND
>
> :-D
--
Gary Stainburn
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]