Juman wrote:
>
> I'm trying to make perl print out some status info while doing other
> things but the actual text isn't shown until a newline character is
> passes.
>
> print "Before";
> sleep (5);
> print "After\n";
>
> This test will print "BeforeAfter" after 5 seconds sleep? How do I make
> it print "Before" sleep 5 seconds and then print "After"?
>
> Don't know if this has to do with Perl or the Bash shell I'm using
> though...

Yep. Morbus is right (although I doubt it's his real name :)

You may want to play with the cryptic internal variable $|, but
I prefer:

  use strict;
  use warnings;

  use IO::Handle;

  autoflush STDOUT;
  autoflush STDERR;

  print 'Before';
  sleep 5;
  print 'After', "\n";


HTH,

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to