Bob Showalter wrote: > > > From: Chad Kellerman [mailto:[EMAIL PROTECTED]] > > > > I have only been writing perl for a few months, so forgive > > me if this > > sounds stupid. > > No, it's an excellent question. > > > what is the difference between: > > > > $| = 1; > > and > > $|++; > > The first assigns the value 1 to the variable $| > The second increments (adds 1 to) the current value of $| > > $| is a "special" variable to Perl. It controls the automatic flushing of > output filehandles after a print(). The default is 0, which means no > auto-flush. Setting it to 1 (or any non-zero value) enables the > auto-flushing. > > Assuming these statements appeared at the top of the program, the effect > would be the same for each. I prefer the first form to the second, since it > is not dependent on what other code may or may not be doing to $| (i.e. > consider if $| were -1 prior to the increment). ^^^^^^^^^^^^^
It's not going to happen Bob! :-) $| is very magical and can only hold the values zero and one. $ perl -le'for (-5, -1, 0, 1, 5) {$| = $_; print $|}' 1 1 0 1 1 Also, $| has an interesting property when you decrement it. $ perl -le'for (1 .. 6) {$|--; print $|}' 1 0 1 0 1 0 Which it doesn't have when you increment it. $ perl -le'for (1 .. 6) {$|++; print $|}' 1 1 1 1 1 1 John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]