#!/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); printf ($print,"$bar","$percent"); sleep (1); } print "nSuccess!n";
実際に動かすと下記のようになります。
[root@orbit ~]# perl ber.pl
[#################### ] 30%
0 Comments.