Gennady Bystritsky
11/2/2006 12:34:00 AM
list-bounce@example.com wrote:
> Pretty new to ruby (and programming but am getting better).
>
> I am importing data with DBI and I want display and counter as each
> row is imported. I can get the display to show:
>
> 1
> 2
> 3
> 4
> 5
> 6
> 7
> 8
> 9
> 10
> etc...
>
> but I don't want a linebreak after the counter is displayed. I want it
> just to keep refreshing itself, basically. Am I missing something
> with puts or print or p? Any ideas?
$stdout.sync = true
20.times do |_counter|
counter = _counter.to_s
print counter + "\b" * counter.size
sleep 1
end
FYI: puts and p both add "\n" to the output if it is not yet there.
Gennady.