Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^7: exchanging strings on the network

by mattk (Pilgrim)
on May 10, 2005 at 11:34 UTC ( #455523=note: print w/replies, xml ) Need Help??


in reply to Re^6: exchanging strings on the network
in thread exchanging strings on the network

STDOUT is line buffered by default, meaning you won't see any text until you print a newline to it (or until perl exits and flushes its buffers on its way out):
print "one two three"; sleep 5; print "four five six\n";
This should stay blank for 5 seconds and then print out all of the text. If you want your prints to STDOUT to appear immediately, set the global variable $| to 1. This sets autoflushing on the currently selected filehandle, which by default is STDOUT:
$|++; print "one two three"; sleep 5; print "four five six\n";
This should print out the first line, sleep 5 seconds, and then print out the second. Easy! Keep in mind terminals buffer output for performance reasons, so don't do this if you're printing out a large amount of data. You probably won't hit this wall while you're still learning, though.

Update: Ah, sorry, not quite. The problem is this: print $client "Username $user Pass $pass";
You don't send through a "\n" at the end. The client is done sending data so it tries to read from the socket again, but the server is still blocking, waiting for a newline that will never arrive. This is what's known as a deadlock.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://455523]
help
Chatterbox?
[ambrus]: Corion: which coordinate system is the upside down one?
[Corion]: ambrus: "the other" ;) To me, "normal" for GUIs means (0,0) is left-upper corner of the monitor/window. But for Prima, the lower-left corner it is ;)
[Corion]: Which would be OK for mathematics and paper, for me ;)
[ambrus]: Ok, so Prima has a postscript-like coordinate system

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2016-12-09 10:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (150 votes). Check out past polls.