In my script I check for the existence of elements compared to a set of data that I already have, I do this multiple time, hence the progress bar.
This is what I am doing as of now
### A loop which is done multiple times ###
my $i =1;
my $page = 50;
while ($i <= $page)
{
##### Part where I print my progress bar ######
print "\rProgress:[";
my $completed =($i/$page)*100;
$completed = ceil($completed);
my $l= $completed;
while ($l>0){
print "#";
$l--;
}
my $remaining = 100-$completed;
while ($remaining>0){
print " ";
$m--;
}
print "] ";
print $completed . "% Complete";
######### Part where I check and keep count #############
foreach (@each_job)
{
my $temp = $_;
# Count number of jobs that exist with my set
if ($job{"$temp"} == 1)
{
$does_exist++ ;
## print "\n Exists - $does_exist"; #Confused for this print
}
else
{
$does_not_exist++;
## print "\n Does not exist - $does_not_exist"; #Confused for this print
};
};
$i++;
}
So what I currently get is something like
Progress:[################################################ ] 48% Complete
Which works fine and displays the progress bar as a traverse page by page.
But what I want is something like this –
Progress:[################################################ ] 48% Complete
Exists - 3
Does Not Exist - 5
Which keeps getting updated at the same spot (using \r).
Can someone help me ?
Use a curses library which handles all the escape code rigamarole for you, and lets you get down to just updating regions of the screen.
Start with this CPAN search for curses modules.