Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

progress bar

by Anonymous Monk
on Aug 15, 2006 at 02:42 UTC ( [id://567383]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Oh wise ones,
I have a text file processing program, and would like to diplay the progress as "=" signs (eg: up to 10, then erase line). So basically it almost looks like a progress bar for RPM installations.
I've hit a blank and could use your help. Any help would be greatly appreciated.

Replies are listed 'Best First'.
Re: progress bar
by McDarren (Abbot) on Aug 15, 2006 at 02:49 UTC
Re: progress bar
by HuckinFappy (Pilgrim) on Aug 15, 2006 at 02:56 UTC
Re: progress bar
by Faile (Novice) on Aug 15, 2006 at 04:13 UTC
    if you know in advance how many lines/files you're processing you can do this, otherwise you can only display a bar that lenghtens by a unit each time you start processing another file. you basically have to insert a printing statement without a \n in the loop of the file/line processing statements. i've done this a few times, let me know if that didnt help :)
      if you know in advance how many lines/files you're processing you can do this, otherwise you can only display a bar that lenghtens by a unit each time you start processing another file.
      Not (completely) true. You will always know the size of the file you are processing, well at least if it is a regular file, not a socket or something similar. If you know the size, count the bytes you have already processed and your progress bar will always be accurate.


      holli, /regexed monk/
Re: progress bar
by liverpole (Monsignor) on Aug 15, 2006 at 13:29 UTC
    An almost identical question was asked here, and I suggested this code, as an example of a subroutine which creates a "closure" to manage the desired progress meter.

    Please try it out; I think it will do what you need.


    s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://567383]
Approved by McDarren
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-10-05 13:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (43 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.