Home: Perl Programming Help: Intermediate:
print caching?



aaaone
New User

Jan 9, 2008, 10:51 AM


Views: 3477
print caching?

Hi! Who can explain why in this simple code "2" is not printed? And why it is printed if I use < print "2\n"; > ?

Thanks! (xpsp2, activestate perl 5.8)

----------------------------------------

use threads;

print "one\n";
async {
while (true)
{
print "1\n";
sleep 1;
}
};

print "two\n";
async {
while (false)
{
print "2"; # if "2\n" then it prints!!!
sleep 2;
}
};

print "waiting...";
<STDIN>;


KevinR
Veteran


Jan 10, 2008, 1:07 PM


Views: 3469
Re: [aaaone] print caching?

\n signals the system to flush the buffer I suppose.
-------------------------------------------------


aaaone
New User

Jan 18, 2008, 12:19 PM


Views: 3458
Re: [KevinR] print caching?

yeah.. thanks, but now I coped with that, using $|

... but working with STDOUT is more simplier, than with sockets... on Win32