Re: Piping Strangeness
Re: Piping Strangeness
- Subject: Re: Piping Strangeness
- From: Sherm Pendley <email@hidden>
- Date: Sat, 30 Nov 2002 13:47:49 -0500
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?
_______________________________________________
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.