in reply to print problem

Hi Punto,

Yes, is the short answer to your question. Here is some code that works:

#! /usr/bin/perl -w use strict; $| = 1; # This forces your selected filehandle (STDOUT # in this case) to be unbuffered. my $i = 0; while (1) { sleep(1); print $i++," - ",$i++," - ",$i++,"\r"; }

There are other ways to do this that might be more elegant or more cross-platform. I believe that looking on CPAN for Term and Curses might be useful to you. (Note to self: finish up that stinking Curses tutorial already...)

Good luck,
{NULE}
--
http://www.nule.org

Replies are listed 'Best First'.
Re: Re: print problem
by hossman (Prior) on Dec 21, 2001 at 07:32 UTC
    The reason you need to set $| is explained in "perldoc perlvar"...
        $|    If set to nonzero, forces a flush right away and
              after every write or print on the currently
              selected output channel.  Default is 0
              ...
              STDOUT will typically be line buffered if output
              is to the terminal and block buffered otherwise.
              ...
    
    So in your orriginal program, the buffer was just building up because it never say a line termination. (and when you switched to "\n" it did).