in reply to Re: Problem with Perl editors.
in thread Problem with Perl editors.

I would suggest $|=1; instead, just because it's a good habit. I've seen moronic situations where $| gets set to -1 (by a previous mistake by another coder) and thus the $|++ I put in place didn't exactly have the desired effect. ;-)

Much better, IMO, to explicitly say what you mean.

Larry Wall is Yoda: there is no try{}
The Code that can be seen is not the true Code

Replies are listed 'Best First'.
Re^3: Problem with Perl editors.
by Corion (Patriarch) on Jul 05, 2005 at 16:16 UTC

    Are you sure?

    perl -e "$| = -1; print $|"

    $| is magical in that it can only have the values 1 and 0. $|++ switches unbuffering on, while $|-- toggles from on to off and back to on.

      Hm, this works on my current Perl installation, but I remember running into the problem as I explained it. Odd; I wonder if it was an old Perl, or something custom on that system...

      Larry Wall is Yoda: there is no try{}
      The Code that can be seen is not the true Code

      I echo radiantmatrix's comment: better to explicitly say what you mean.

      Where alternate 1 does the job, but offers no significant performance advantage, is not significantly shorter and is obscure (to any degree), then alternate 2 which is explicit is always better (unless of course you are writing deliberatly obscure code).


      Perl is Huffman encoded by design.
Re^3: Problem with Perl editors.
by blazar (Canon) on Jul 06, 2005 at 08:35 UTC
    I've seen moronic situations where $| gets set to -1
    Huh?!? I would be curious to know how to do so, since AFAIK it is not actually possible:
    $ perl -le 'print $|=-1' 1

      You may wish to read my response to Corion. I recall an app where $|-- was called twice, and when I printed the value of $| while debugging, I showed '-1' as its value. This was a long time ago, and perhaps was something unique about the environment -- I had assumed all this time that it was normal Perl behavior, but it appears I'm wrong.

      Larry Wall is Yoda: there is no try{}
      The Code that can be seen is not the true Code