in reply to Strange Behavior

You didn't print a final "\n", and autoflush is not enabled. The process dies before the output gets flushed.

Add this to your code, somewhere before the last print:

$|++;
(There are other, more elegant ways to do this too.)

-QM
--
Quantum Mechanics: The dreams stuff is made of

Replies are listed 'Best First'.
Re^2: Strange Behavior
by tlm (Prior) on Mar 23, 2005 at 00:05 UTC

    I don't understand why $|++ is universally preferred (or at least so it seems to me) over the more straightforward $|=1. What's the reason?

    What bugs me about $|++ is that it implies that there are levels of unbuffering, and that with $|++ we are getting more unbuffering than whatever we had before.

    And heaven forbid that some clown earlier on had the cute idea of unbuffering the selected handle with something like $|--. Come to think of it, $|++ seems to me every bit as bad as $|--.

    the lowliest monk

    Update: Fixed some awkward grammar.

      Can't speak for others, I use $|++ 'cause it's easier for me to see and find in Sources than $| = 1.

      Ordinary morality is for ordinary people. -- Aleister Crowley
      I don't understand why $|++ is universally preferred (or at least so it seems to me) over the more straightforward $|=1. What's the reason?
      Perhaps your "Perl Sense" is underdeveloped? $var++ can be either a counter or a boolean. It's the context that's important (as with so many things in Perl). I'd wager that most Perlers distinguish between the use of ++ and how the object is used.

      If you feel the need to be explicit, you might like this:

      use IO::Handle; STDOUT->autoflush(1); # OO form autoflush STDOUT 1; # procedural form

      -QM
      --
      Quantum Mechanics: The dreams stuff is made of