On Thu, Sep 13, 2001 at 08:23:10AM -0600, Michael Burnside wrote:
> Using the code below works great if STDOUT is the terminal, but when
> trying to pipe it to a file the two system() functions run first and the
> print() statements run second, illustrated below as well.  Anyone have a
> clue why?

You appear to be suffering from buffering.  See
http://perl.plover.com/FAQs/Buffering.html.  It's not that the print
statements "run" second, it's that the printed data is buffered and only
output when the buffer is full, or the program exits.  The difference
between STDOUT and a file is that STDOUT is a terminal, and thus line
buffered, whereas a file is simply block buffered.  The moral of the story
is, you need to flush output between prints, either manually with
IO::Handle's flush() method, or automatically, by setting $| to a true
value.


Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to