How is setting $| = 1 going to avoid buffering problems when calling system() on a non-Perl program?
I believe you are referring to fork(), and exec(), not system(). I also believe that modern versions of Perl include special code in fork() and exec() to implicitly flush all open file handles.
UPDATE: After discussing with grantm, the problem that he was dealing with in the past was a parent process expecting output from the perl script and a child of the perl script in the proper order, such as would be the case for a CGI that wishes to insert the output of a shell command directly into the HTML at a certain point. In this case, in order for the parent to see the output in the correct order, the output must be flushed before the shell command is executed. At least Perl 5.8.0 does this automatically for all systems that support the 'flush all handles' semantics (often fflush(NULL)). I recommend not using auto-flushing for CGI handles as it unnecessarily breaks the writes up into separate system calls, leading to inefficient web page serving. Flush when necessary, and let Perl autoflush when necessary.
In reply to Re: Re: Using perl to call a shell command?
by MarkM
in thread Using perl to call a shell command?
by Eccentric
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |