Re: Why doesn't this work?



HerbF@xxxxxxxxxxxxx wrote:
Glenn Jackman wrote:
At 2009-08-20 02:08PM, "HerbF@xxxxxxxxxxxxx" wrote:
I'm trying to write a simple routine to print a character every second. I
have:

foreach (1..5) {
print "*";
sleep 1;
}

When I run it, it waits for the full 5 seconds to tick by, and then prints
the string '*****'. Why doesn't it print an asterisk every second until
finished?

Your output is buffered. Set $|=1 first.

Tried that, but it made no difference.

Then something else is buffering on top of Perl's buffering. See
'perldoc -q buffer' for some in-depth discussion and for other ways to
work around buffering.

jue
.