Perlで進行状況(プログレスバー)をモジュールを使わず作る 3

#!/user/bin/perl
$max = '30';
$len = '50';
for ($num = 0;$num<=$max;$num++) {
local $| = 1;
$percent = int(($num/$max)*100);
$print = "["."%-"."$len"."s"."] "."%d%%"."r";
$bar = '=' x int(($percent/100)*$len);
if (int(($percent/100)*$len) < $len) {$bar .= '>';}
printf ($print,"$bar","$percent");
sleep (1);
}
print "nSuccess!n";

実際に実行すると下記の様になります。
[root@orbit ~]# perl ber.pl
[=================>                                         ] 26%

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(Spamcheck Enabled)

日本語が含まれない投稿は無視されますのでご注意ください。(スパム対策)