Mostly it just provides another example of ugly code that gives my Python-using friends a chance to point and gloat. Everybody else has already explained the practical application of setting autoflush. Smack anybody who uses the ++ version, though. That's just not right.

Incidentally, I prefer to avoid this particular messy form and rely on IO::Handle.

use IO::Handle; my $fh = IO::Handle->new(); if ($fh->fdopen("dump.dat", "w")) { $fh->autoflush(1); $fh->print($mystuff); # ... blah blah blah $fh->close() or die("Unable to close file: $!\n"); } else { die("Unable to open file: $!\n"); }

... but that's just me. I like the typing exercise if it makes it easier for me to read the code out loud.


In reply to Re: What the heck does $|++; do? by webfiend
in thread What the heck does $|++; do? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":