This is pulled from a script I have that loops through over 500,000 database 
records, correlates data and does a bunch of other junk.  It shows a progress 
bar, the percentage, and an estimated "time left" deallie.  It's actually 
quite a cool tool.

use Term::ProgressBar;
$max = $maxcount;  # Max number of loops, if known
$count = 0;
$next_update = 0;
$progress = Term::ProgressBar->new ({
    name  => 'Progress-Bar Title',
    count => $max,
    ETA   => 'linear',
});
$progress->max_update_rate(1);
$progress->minor(0);
while (do your work here) {
    $count++;
    $next_update = $progress->update($count) if ($count >= $next_update);
    # Do your stuff that requires lotsa loops here
}
$progress->update($max) if ($max >= $next_update);

On Friday 20 June 2003 11:13 am, Craig Sharp wrote:
> I need to put a counter in a script that processes a file line by line.
> I want the counter to alway stays on the same line on the console but
> increment.  This is to be a baby sitter so that the user can see the
> numbers increase.  I do not want to scroll but print the number, erase
> and print the next number untill finished.
>
> I hope this makes sense.
>
> Thanks,
>
> Craig A. Sharp
> Unix Systems Administrator
> DNS Administrator
> Security Administrator
> Roush Industries
> Office: 734-466-6286
> Cell: 734-231-6769
> Fax: 734-466-6939
> [EMAIL PROTECTED]
> ====================================================
> I have not lost my mind, it's backed up on tape somewhere!
> ====================================================
> _______________________________________________
> Perl-Unix-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

-- 
Michael A Nachbaur <[EMAIL PROTECTED]>

_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to