Subject: Re: print isn't flashed using PERL by MSWin32 on Windows XP
'flash' and 'flush' are two different things. ITYM 'flush'.
Not PERL, Perl.
Sorry to bother again, but it doesn't work.
What doesn't work? Please quote an appropriate amount of context when
you are responding. Please read the posting guidelines posted here
regularly.
And when looking again in this group I found this problem already
reported some 9 years ago:
************************************************************
Tungning Cherng Sep 9 1996, 12:00 am show options
There is no point in cutting and pasting from Google like this. What if
I wanted to check other messages in that thread? It would have been far
more useful to use the message ID to refer to the message.
I'm not sure that they originate from the same problem, but
still I don't have a solution. For now I simply add "\n"s.
Maybe I am very easily confused, but this got me curious so I decided to
test is myself. Here is the code:
#! /usr/bin/perl
use strict;
use warnings;
$| = 1;
while(<STDIN>) {
print "$. << ";
if (eof) {
print "lastline: $_";
} else {
print "entered: $_";
}
}
__END__
Notice that I am not chomp'ing $_ after input. So, I would expect to see
the following when I run this script:
D:\Home\asu1\UseNet\clpmisc> t
one
1 << entered : one
two
2 << entered : two
....
In fact, I would have expected this output even without setting
autoflush on. Instead, what get is:
D:\Home\asu1\UseNet\clpmisc> t
one
1 << two
entered : one
2 << three
entered : two
3 <<
....
If I change the code to:
#! /usr/bin/perl
use strict;
use warnings;
my $t = time;
while(<STDIN>) {
print "$. << ";
if ($t > time) {
print "lastline : $_";
} else {
print "entered : $_";
}
}
__END__
I get:
D:\Home\asu1\UseNet\clpmisc> t
one
1 << entered : one
two
2 << entered : two
....
So, the culprit seems to be the call to eof.
Now, the documentation of eof does indeed state that it is not very
useful in an interactive setting, and I do not think I have a line of
code anywhere with a call to eof in it (be it C, Java or Perl). Granting
that, I am still a little confused about this behavior.
Sinan.