aramsey has asked for the wisdom of the Perl Monks concerning the following question:
I'm having some trouble using the progress bar for the first time. I'm running a copy in a thread and once everything else completes I want to monitor the progress. The example snippets I gave result in the bar completing @ 5%.#!/usr/bin/perl use threads; use threads::shared; use Term::ProgressBar; ${$task . '_src_filesize'}; share(${$task . '_src_filesize'}); ${$task . '_dst_filesize'}; share(${$task . '_dst_filesize'}); # fork copy to a new thread, so it runs in the background ${'copy_' . $task . '_thread'} = threads->create(sub { print "Copying: $task/dist/$task.zip to /mnt/nfs/$task/$rel.zip\n" +; system("cp $task/dist/$task.zip /mnt/nfs/$task/$rel.zip"); while (${$task . '_src_filesize'} != ${$task . '_dst_filesize'} ) +{ ${$task . '_dst_filesize'} = stat("/mnt/nfs/$task/$rel.zip")-> +size; } if (-e "/mnt/nfs/$task/$rel.zip") { print "Copied: $task/dist/$task.zip to /mnt/nfs/$task/$rel.zip +\n"; unlink("$task/dist/$task.zip"); } }); $progress = Term::ProgressBar->new({ name => 'Copy', count => ${$task . '_src_filesize'}, ETA => 'linear', }); $progress->minor(0); while (${$task . '_src_filesize'} != ${$task . '_dst_filesize'}) { $progress->update(${$task . '_dst_filesize'}) }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Term::Progress bar completes at 5%
by bart (Canon) on Jun 19, 2012 at 20:07 UTC | |
by aramsey (Initiate) on Jun 19, 2012 at 21:43 UTC | |
|
Re: Term::Progress bar completes at 5%
by zentara (Cardinal) on Jun 19, 2012 at 17:59 UTC | |
by aramsey (Initiate) on Jun 19, 2012 at 20:10 UTC |