in reply to Win32::Console problem

Add $|++; at the top of the program.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP PCW It is as I've been saying!(Audio until 20090817)

Replies are listed 'Best First'.
Re^2: Win32::Console problem
by hoffy (Acolyte) on Nov 23, 2009 at 04:55 UTC

    Thanks! Seems so simple and it works!

    Now, I do have a non essential quest for knowledge....why did it work on V5.6 but no V5.8?

      why did it work on V5.6 but no V5.8?

      The rules regarding automatic flushing of the STDOUT buffer changed from perl-5.6 to perl-5.8. Setting $| (or incrementing it from 0 to 1, as per BrowserUk's approach) is the way to make sure that the perl-5.8 STDOUT buffer gets flushed in much the same way as happened automatically with perl-5.6.

      For a simple demo of the difference, the following outputs hellogoodbye on 5.6, but goodbyehello on 5.8:
      perl -e "print STDOUT \"hello\";print STDERR \"goodbye\""
      Setting $| will ensure that hellogoodbye is output on both 5.6 and 5.8:
      perl -e "$|=1;print STDOUT \"hello\";print STDERR \"goodbye\""
      Cheers,
      Rob
      why did it work on V5.6 but no V5.8?

      I have no idea.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.