CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
print caching?

 



aaaone
New User

Jan 9, 2008, 10:51 AM

Post #1 of 3 (1698 views)
print caching? Can't Post

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

Post #2 of 3 (1690 views)
Re: [aaaone] print caching? [In reply to] Can't Post

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


aaaone
New User

Jan 18, 2008, 12:19 PM

Post #3 of 3 (1679 views)
Re: [KevinR] print caching? [In reply to] Can't Post

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

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

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives