Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • See also

    $ perl -wle'print $|++ for 1 .. 10'     
    0
    1
    1
    1
    1
    1
    1
    1
    1
    1

    $| only has two values, 0 and 1. I thought this was documented in perlvar but it doesn't seem to be. Perhaps it should be.

    • Sure it is, "... $| tells you only whether you've asked Perl explicitly to flush after each write ..."

      To me that sounds like it will return the moral equivalent of true or false (zero and one in this case) based on what the state of $| is.
      --
      Casey West
      • by KM (4) on 2002.08.20 8:28 (#11977) Journal
        Yes, that's how it works. It is a switch, on (1) or off (0). But, why would, in the case if this variable, substracting from 0 makes it 1? If that is a 'feature', I wouldn't mind knowing what the feature is :)

        Actually, this also occurs with $^W:

        # perl -le 'print $^W; $^W--; print $^W';
        0
        1