On Oct 16, 6:11 am, [EMAIL PROTECTED] (Chas. Owens) wrote: > On 10/15/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > > I would expect the following script: > > > use strict; > > use warnings; > > print 8*8; > > sleep 3; > > print 7*7; > > > To behave as follows. > > > 1. print 64. > > 2. pause 3 seconds. > > 3. print 49. > > > Instead the behavior is: > > > 1. pause 3 seconds. > > 2. print 64. > > 3. print 49. > > > Why is that, and how do I insert a pause in between these two print > > commands (as an example)? > > > BTW, I did perldoc -f sleep. If it explains this behavior, I didn't > > understand it. > > snip > > You didn't find anything in perldoc -f sleep because the problem is > not with sleep. The pause is there, but STDOUT is buffered by default > so you will not see the result of the first print until the buffer is > full, you print a \n, or the program exits. Try this instead: > > use strict; > use warnings; > print 8*8, "\n"; > sleep 3; > print 7*7, "\n";
Rather than changing the output by adding newlines, you can simply turn output buffering off: $|++; Read about the $| variable in `perldoc perlvar` Paul Lalli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/