0

perl进度条


收藏个perl的进度条

  1. #!/usr/bin/perl -w
  2. $n = 27;
  3. for($i=1;$i<=$n;$i++){
  4. proc_bar($i,$n);
  5. select(undef, undef, undef, 0.2);
  6. }
  7. print "\n";
  8.  
  9. sub proc_bar{
  10. local $| = 1;
  11. my $i = $_[0] || return 0;
  12. my $n = $_[1] || return 0;
  13. print "\r\033[36m[\033[33m".("|" x int(($i/$n)*50)).
  14. (" " x (50 - int(($i/$n)*50)))."\033[36m]";
  15. printf("%2.1f%%\033[0m",$i/$n*100);
  16. local $| = 0;
  17. }

我猜~这些文章你可能也感兴趣

暂时没有留言..

给我留言:

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word