in reply to Outputing a simple counter to stdout on the same line.
$| = 1; for my $i ( 1..10 ) { print $i, "\r"; sleep 1; }
$| = 1 does the magic. It turns on autoflush on the currently selected filehandle (stdout, by default).
The \r in print "...\r" sends the cursor back to the beginning of the line
$| is described in perlvar
|
|---|