#!/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'}) }
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%.

In reply to Term::Progress bar completes at 5% by aramsey

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.