• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Piping Strangeness
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Piping Strangeness
      • From: mw <email@hidden>
References: 
 >Re: Piping Strangeness (From: mw <email@hidden>)

  • Prev by Date: Re: Add Toolbar to Document Based Project
  • Next by Date: Re: Problem with object communication
  • Previous by thread: Re: Piping Strangeness
  • Next by thread: Re: Piping Strangeness
  • Index(es):
    • Date
    • Thread