[OT?] sleep()-problem in perl

2002-11-11 Thread Johannes Jörg
Hello Everybody
Could someone tell me why this works:

#!/usr/bin/perl -w
for ($i=0;$i=10;$i++){
  print sleeping...\n;
  sleep 1;
}
 
and this one does not:

#!/usr/bin/perl -w
for ($i=0;$i=10;$i++){
  print sleeping...;
  sleep 1;
}

Note: Only the newline inside the print-command is missing. The first
example works as expected (prints one line of sleeping... per second), while the
second example does nothing (not even prints the sleeping... before sleep()
is called).
The behaviour does not change if I try single quotes instead of double
quotes, and not if I write brackets around the print argument.
This happens on woody perl, I could not yet try it out on sid.
Any idea?

joerg

-- 
+++ GMX - Mail, Messaging  more  http://www.gmx.net +++
NEU: Mit GMX ins Internet. Rund um die Uhr für 1 ct/ Min. surfen!


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]




Re: [OT?] sleep()-problem in perl

2002-11-11 Thread Colin Watson
On Mon, Nov 11, 2002 at 05:08:55PM +0100, Johannes J?rg wrote:
 Could someone tell me why this works:
 
 #!/usr/bin/perl -w
 for ($i=0;$i=10;$i++){
   print sleeping...\n;
   sleep 1;
 }
  
 and this one does not:
 
 #!/usr/bin/perl -w
 for ($i=0;$i=10;$i++){
   print sleeping...;
   sleep 1;
 }

Standard output is usually line buffered when printing to a terminal, so
your output may not appear until you print a newline. Set $| = 1 if you
want to change this, and see perlvar(1).

Cheers,

-- 
Colin Watson  [[EMAIL PROTECTED]]


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]