Re: Piping Strangeness
Re: Piping Strangeness
- Subject: Re: Piping Strangeness
- From: mw <email@hidden>
- Date: Sat, 30 Nov 2002 14:03:21 -0500
On 11/30/02 1:47 PM, "Sherm Pendley" <email@hidden> wrote:
>
On Saturday, November 30, 2002, at 10:27 AM, mw wrote:
>
>
> Oops, nevermind everybody. I was forgetting to send closeFile to the
>
> file
>
> handle I was using for writing. Some simple slightly-longer research
>
> did the
>
> trick!
>
>
Perl's output is line-buffered by default, which means the parent
>
program won't be able to read anything until the Perl program sends a
>
newline.
>
>
Closing the input to your Perl program will work, if your Perl program
>
is basically just a filter - something like this:
>
>
while (<>) {
>
...
>
}
>
>
In the above case, the Perl program ends when it runs out of input, and
>
when it ends, anything left in its output buffer is flushed.
>
>
In cases where more interactivity is required, where you need to gather
>
some output from the program without waiting for it to end, you can turn
>
off Perl's line-oriented output buffering. You do that by setting $| to
>
a true value. A memory aid - it's the pipe symbol, so set it to true if
>
you want piping hot output. Corny, I know - but it works for me. If you
>
use the English module, you can also refer to it as $OUTPUT_AUTOFLUSH.
>
>
sherm--
>
>
If you listen to a UNIX shell, can you hear the C?
>
The way I was doing it was using the print command in Perl. That send back
text (and other data) to the Cocoa program. Maybe I just didn't see the
sideeffects of not sending back a \n because it was a 3 line Perl program?
;-)
Otherwise, couldn't I just send \n characters at the end of the print
statements to have it flush back?
One more question that I forgot to ask the rest of the list. How can I have
both read and write NSPipes open at the same time? It seems to be quite
cumbersome to have to close one of the pipes every time you want to perform
a read/write operation. It says in the docs how to go about this by using a
handle to an NSPipe (and then recommends against doing it) which will keep
the other pipe (whether that be read or write) from being closed. Any
thoughts on how to get this "handle"?
TIA,
mw
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.