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

In an answer to haukex, I've included a link to a blog post that mentions how tqdm might be used. The tqdm PyPI page itself (which I linked in the original post) is also very informative already. But as usual I probably didn't communicate clearly what exactly I want to accomplish, so let me reiterate: how would one create a progress bar library in Perl that is roughly as simple to use to an existing script. By simple I mean with as minimal change as possible, adding as few characters of code as possible. And with existing script, this implies that some uses for() and some uses while() (I personally use for() far more often than while()).

In this interface:

for (1..100) { tqdm; # same as tqdm($_); ... }

we can just assume that the first time tqdm() is first invoked is the start of the process. But tqdm() didn't receive the target number (100).

Replies are listed 'Best First'.
Re^3: Porting tqdm to Perl
by LanX (Saint) on Dec 21, 2018 at 14:11 UTC
    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

      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.