IIRC are (should be?) all iterators in Python objects inheriting from a class Iteratable.
tqdm can just take one such object and return another enhanced iteratable one. (please correct me if I'm wrong)
Perl has a multitude of different iterators, finding a standard procedure to change them should be difficult.
I think the best way to go is to write tqdm into the loop (if it does what I understand)
for (1..100) { tqdm; # same as tqdm($_); ... }
Now the problem you'd be facing is extra code for initialisation, i.e. how can you tell that the loop was freshly entered or not?
IMHO the default answer in Perl is to initialize that tqdm right before the loop starts.
for my $outer (1..10) { my $tqdm = ProgressBar->new(); # or another constructor for (1..100) { &$tqdm; ... } }
Of course TIMTOWTDI, but I hope this helps.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
In reply to Re: Porting tqdm to Perl
by LanX
in thread Porting tqdm to Perl
by perlancar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |