Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Using "Sleep "

Reply
Thread Tools

Using "Sleep "

 
 
George Kinley
Guest
Posts: n/a
 
      09-09-2004
for(;
{
print "a";
sleep (1);
}

The above script does not print any thing on console , till I modify
it like

for(;
{
print "a\n";
sleep (1);

}
why?

--
-Gk
 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      09-09-2004
"George Kinley" <(E-Mail Removed)> wrote in message
news:vCY%c.24967$(E-Mail Removed)...
> for(;
> {
> print "a";
> sleep (1);
> }
>
> The above script does not print any thing on console , till I modify
> it like
>
> for(;
> {
> print "a\n";
> sleep (1);
>
> }
> why?


This is known as output buffering. By default, STDOUT is line-buffered,
meaning the printed strings get stored until a newline is reached, at
which point everything is printed. This is controlled by the $|
variable.

Read
perldoc -q buffer
and
perldoc perlvar

to learn more about it.

Paul Lalli


 
Reply With Quote
 
 
 
 
Eric Bohlman
Guest
Posts: n/a
 
      09-09-2004
"George Kinley" <(E-Mail Removed)> wrote in
news:vCY%c.24967$(E-Mail Removed):

> for(;
> {
> print "a";
> sleep (1);
> }
>
> The above script does not print any thing on console , till I modify
> it like
>
> for(;
> {
> print "a\n";
> sleep (1);
>
> }
> why?


Output buffering. perldoc -q flush will give you the detailed answer and
the appropriate workaround.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using a Link Button to redirect to another page by using data from =?Utf-8?B?R1REcml2ZXI=?= ASP .Net 1 02-16-2005 07:04 PM
Error page using the Application_Error void dosnt work when using DIV for a please wait message s_erez@hotmail.com ASP .Net 2 12-24-2004 12:11 PM
no code in webform using vs.net, but in webform using notepad timmso ASP .Net 1 12-12-2003 04:30 PM
Using GetOleDbSchemaTable to get SQL Server Field Description - using pete ASP .Net 1 08-29-2003 10:50 AM
Re: MVP? Index error on nested element using System.xml but NOT using msxml??? William F. Robertson, Jr. ASP .Net 1 06-25-2003 08:08 PM



Advertisments