progress bar in command line perl script

后端 未结 3 1184
时光取名叫无心
时光取名叫无心 2021-01-05 15:48

I am trying to print progress in % in command prompt. But it is not working properly.

I want to print the progress as :: Status 10% Completed when 20% will complete

3条回答
  •  执念已碎
    2021-01-05 16:53

    You can do something like this:

    use strict;
    use warnings;
    
    use Time::HiRes qw(usleep);
    local $| = 1;
    
    my @nums = 1 .. 20;
    
    foreach my $c (@nums) {
      print "$c";
      usleep(100000);
      print ("\b" x length($c));
    }
    print "\n";
    

提交回复
热议问题