I tried your test myself on two different systems, and got the same results.
Could this be a perl bug?
The only way I could find to avoid it was to use the shell print command as
follows:
while () {
$line="hello world";
system ("echo -n $line");
sleep 1;
}
Interesting little problem.
John F. Baskette
> ----------
> From: Dan[SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, July 27, 2000 8:03 AM
> To: [EMAIL PROTECTED]
> Subject: A simple perl question.
>
> Here's one that's driving me mad ... I'm trying to write a script and I
> want
> the output to continue on the same line, but when I add in anything that
> slows down the loop I can only get an output if I add a line feed.
>
> (RH 6.1 and perl-5.00503-6.)
>
> Any ideas?
>
> Dan.
>
> Three example are below to try and explain what I mean.
>
> --------------------------------------------------------------------------
> ---
>
> #!/usr/bin/perl
>
> while () {
> print "hello world";
> }
>
> gives
>
> o worldhello worldhello worldhello worldhello worldhello worldhello
> worldhello worldhello worldhello worldhello worldhello worldhello
> worldhello
> worldhello worldhello worldhello worldhello worldhello worldhello
> worldhello
> worldhello worldhello worldhello worldhello worldhello wor
>
> --------------------------------------------------------------------------
> ----
>
> When I add something in that slows the loop down, a subroutine, or even a
> simple sleep command ...
>
> #!/usr/bin/perl
>
> while () {
> print "hello world";
> sleep 1;
> }
>
> I get nothing at all, the cursor just sits there.
>
> --------------------------------------------------------------------------
> ----
>
> Then I add a line feed ...
>
> #!/usr/bin/perl
>
> while () {
> print "hello world\n";
> sleep 1;
> }
>
> And get this ...
>
> hello world
> hello world
> hello world
> hello world
> hello world
> hello world
> hello world
> hello world
>
>
>
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
> the body of a message to [EMAIL PROTECTED]
> Please read the FAQ at http://www.linux-learn.org/faqs
>
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to [EMAIL PROTECTED]
Please read the FAQ at http://www.linux-learn.org/faqs