[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

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



Thanks, Colin.
This example shows that sitting down to the computer, knowing not much more
than how to
'print "Hello World\n";'
and start hacking with a book ("Programming Perl") in your hand is not the
best approach to learn programming. One misses by 100% chance such easy, yet
important things like the $| variable. Nice to know that there are the
"local Perl gurus" (well, not local, more international ;) ) one can ask...
I'm sure I will be coming back in not too far future.
joerg

> > 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                                  [cjwatson@flatline.org.uk]




Reply to: