dhofmeister has asked for the wisdom of the Perl Monks concerning the following question:

(ah, another stdout question!) i'm using perl 5.10 and IPC::Run3 (but it's not necessarily a requirement). i'm writting a perl program that (of course) calls "other programs". all is working reasonably well *except* for getting the stdout of the "other programs" -- in a timely manner. what i get is all the stdout at once when the "other program" ends. i'd rather get the stdout as it occurs. when i call run3, i am saying "run3 ....\&print_stdout" (which is a simple subroutine). is there a(n easy) way around this?

Replies are listed 'Best First'.
Re: capturing stdout in real time
by Illuminatus (Curate) on Aug 20, 2012 at 22:40 UTC
    stdout is normally buffered. Unless you can change the "other programs", or they have a runtime option to change the buffering, you don't have much choice. About the only thing you could do (and this would be messy), would be to get the program to write to a pty -- then it would be line-buffered, which would probably give you the data more quickly

    fnord

Re: capturing stdout in real time
by zentara (Cardinal) on Aug 21, 2012 at 09:27 UTC