in reply to Re^2: Porting tqdm to Perl
in thread Porting tqdm to Perl

and how does tqdm handle infinite iterators?

or how would you handle readline without knowing the number of lines?

or circular iterators?

> But as usual I probably didn't communicate clearly what exactly I want to accomplish

indeed ;-)

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Replies are listed 'Best First'.
Re^4: Porting tqdm to Perl
by perlancar (Hermit) on Dec 21, 2018 at 14:19 UTC

    For a non-infinite iterator (with a known end target), tqdm or a typical progress bar library can show the progress percentage, e.g.:

     20%|###        | 200/1000 (00:03<00:09 98.3it/s)

    For an infinite iterator, like in the case of this command-line (tqdm is also available as a CLI):

    % seq 999999 | tqdm

    the progress library could just show something like:

    203495 (00:03<00:09 99988.3it/s)

    or:

     ??%|      ###  | 203495 (00:03<00:09 99988.3it/s)

    where the progress bar is just animated with a running ### bar, like you would see in various UI.

    A circular iterator wouldn't be problematic, the progress bar would just be reset and start again accordingly. But of course normally the user will not attach a circular iterator if he/she wants to display a progress bar for a process that ends after a certain time.