I usually implement "progress bar" in a command-line application via logging. For example:
use Log::Any::App qw($log);
$log->info("Starting ...");
for my $i (0..@items-1) {
my $item = $items[$i];
$log->infof("(%d/%d) Processing item %s ...", $i+1, ~~@items, $item);
do_stuff($item);
}
$log->info("Finished");
Log::Any::App already gives me an easy way to output those log lines to screen and/or file. I can turn on the log by giving VERBOSE=1 or --verbose to m…
- Using $a and $b outside of sort() can have serious consequences.
You can't name a subroutine m, q, s, y (at least my favorites f and g aren't taken).
Removing duplicate elements from a list:
PHP:
php> $ary = array_unique($ary);
Perl:
$ sudo su
# apt-get install curl
# curl -L http://cpanmin.us | perl - --self-upgrade
# cpanm List::MoreUtils
perl> use List::More…
This post also serves as a reminder to self, to always, Always, ALWAYS check The CPAN first in the future.
Existing module on CPAN (which I failed to discover in time): WWW::PAUSE::CleanUpHomeDir
My solution (UserJS): pause-delete_files-select_all_older_releases_files.user.js
Ref: perlmonks thread
Do you mark favorite distributions on metacpan.org? Do you want to be able to do:
% cpanm -n Task::BeLike::YOURCPANID::Favorited
to install all your favorite modules in one go?
If yes, install Dist::Create::TaskBeLikeFavorited to create your task distribution, then type:
% create-task-belike-favorited-dist YOURCPANID
% cd Task-BeLike-YOURCPANID-Favorited
% dzil release
You…