Вопрос

I'm trying to make a simple text-based progress bar in perl, in order to display the progress while sending an email or doing a task.

Any pointers ?! Thanks

Это было полезно?

Решение 3

I used Term::ProgressBar module, and after each done operation i call update() method. That's all. Thank you all, especially Bill Ruppert ;)

Другие советы

Damian Conway's Smart::Comments module includes text progress bars.

I’m quite fond of Time::Progress for terminal stuff. Simplistic example–

use warnings;
use strict;
use Time::Progress;
use Time::HiRes "usleep"; # for demo.

my $timer = Time::Progress->new();
my $some_total_to_reach = 10_000;
$timer->attr( min => 1, max => $some_total_to_reach );

my $count = 1;
while ( $some_total_to_reach-- )
{
    print $timer->report("Doing stuff: %40b%p%L%E\r", $count++);
    usleep int(rand(1_000));
}

print "\nDone!\n";
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top