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

Re: [MacPerl] \a \new question



At 23.02 +0000 2000.01.02, John Delacour wrote:
>This script gives an alert sound every second
>
>        #!perl -w
>        for $_ (1..8){
>          print "\a\n";
>          sleep 1;
>        }
>
>but if I omit the newline (print "\a") or add any other string not
>including a newline, the seconds and the bells are all added together
>and executed at once after 8 seconds.
>
>Why is this?

Because \n flushes the buffer.  Until the buffer is flushed, nothing will
get printed at all.  The buffer is flushed for \n, for the program exiting
or filehandle closing, or when it gets full.

$| = 1 at the top will "fix" the problem.

-- 
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org