[comp.lang.perl] Non buffered output

crehta@tasu74.UUCP (Ran Ever-Hadani) (12/27/89)

Is there a way to force the statement

print ".";

to put a dot on the screen immediatly after it is issued, rather
than after the output buffer is full?

Below I explain why I need this, just in case anybody is 
interested.

Thanks

-- Ran

----------------------------------------------

I have a perl program which is divided to stages.  I would like
to print out a dot every time a stage finishes, so that an output
such as

doing...................done

is gradually produced.


My program looks something like

print "doing";
<stage 1>
print ".";
<stage 2>
print ".";
<stage 3>
   .
   .
   .
<stage n>
print "done\n";

Having the entire line printed out only when the program finishes (as
it does now) is not very useful.
-----------------------------------------------
Reply-To: crehta@taux01.nsc.com (Ran Ever-Hadani)
Disclaimer: The above is to be attributed to me only, not to any organization.
Apology: Bad English.  E-mailed spelling and style corrections are welcome.

lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (12/28/89)

In article <3146@taux01.UUCP> crehta@taux01.nsc.com (Ran Ever-Hadani) writes:
: Is there a way to force the statement
: 
: print ".";
: 
: to put a dot on the screen immediatly after it is issued, rather
: than after the output buffer is full?

$ grep buffered /usr/man/catn/perl.n
                  select(STDERR); $| = 1;       # make unbuffered
                  select(STDOUT); $| = 1;       # make unbuffered
             line buffered if output is to the terminal and block
             buffered otherwise.  Setting this variable is useful
$ grep flush /usr/man/catn/perl.n
             ciative array before the dbmopen.  You can flush the
             efficient.  Note: exec (and system) do not flush
             unflushed buffers remain unflushed in both
             change the dbm file.  (It does, however, flush any
     $|      If set to nonzero, forces a flush after every write
$ 

There are faster ways of finding out these things than asking the net.

Larry