Search code examples
perlbuffering

Does Perl's $| setting affect system commands?


I am looking at some old code in Perl, where the author has writtern $| = 1 in the first line.

But the code does not have any print statements, it calls a C++ binary using the system command. Now I read that $| will force flush after every print. So does it affect the system command's output in any way or am I safe to remove that line.

Thanks Arvind


Solution

  • I do not believe so. The $| will affect the way that Perl is running, not any external executable.

    You should be safe to remove it.

    perldoc - perlvar : States "If set to nonzero, forces a flush right away and after every write or print on the currently selected output channel.". I think the important thing here is the "currently selected output channel". The external application will have it's own output channel.