如何在 Perl 程序中创建等待省略号? [英] How to create a waiting ellipsis in a Perl program?
本文介绍了如何在 Perl 程序中创建等待省略号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下代码无法正常工作:
The following code is not working as it seems it should be:
print "Processing your listing";
sleep($n);
print ".";
sleep($n);
print ".";
sleep($n);
print ".\n\n";
试图在有 .
的地方得到一些东西,然后是另一个 .
,然后是另一个 .
,然后 过程完成!
Trying to get something where there is a .
, then another .
, then another .
, and then Process complete!
推荐答案
我实际上建议不要手动执行此操作.有很棒的 CPAN 模块提供了你真正想要的功能,一个进度条.例如有:
I'm actually going to suggest against doing this manually. There are fantastic CPAN modules which provide the feature you actually want, a progress bar. For example there are:
以下是来自 ProgressBar::Stack 的示例:
Here's the example from ProgressBar::Stack:
use ProgressBar::Stack;
init_progress;
sleep(1);
update_progress 20;
sleep(2);
update_progress 60;
sleep(2);
update_progress 100;
print "\n";
init_progress(message => "Calculating");
my $sum = 0;
for_progress {
$sum+=$_;
sleep(1);
} 0..10;
print "\nSum = $sum\n";
这篇关于如何在 Perl 程序中创建等待省略号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文