電子メールの送信中またはタスクの実行中に進行状況を表示するために、perlで単純なテキストベースの進行状況バーを作成しようとしています。
任意のポインタ?!ありがとう
電子メールの送信中またはタスクの実行中に進行状況を表示するために、perlで単純なテキストベースの進行状況バーを作成しようとしています。
任意のポインタ?!ありがとう
Damian Conway のSmart::Commentsモジュールには、テキスト プログレス バーが含まれています。
私は、ターミナル関連のTime::Progressがとても好きです。単純な例–</p>
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";
私は Term::ProgressBar モジュールを使用し、操作が完了するたびに update() メソッドを呼び出します。それで全部です。皆さん、特にビル・ルパートに感謝します ;)