October 2012 Archives

Progress::Any

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…

Why you shouldn't write short code examples in Perl

  • 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…

    Another Perl's doomsday statistics?

    From ohloh.net:

    ohlol-langs-20121004-commits.png

    ohlol-langs-20121005-contributors.png

    ohlol-langs-20121006-locs.png

    ="o…

    Cleaning up your PAUSE account

    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

    Your own Task::BeLike::$AUTHOR::Favorited

    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…

    About Steven Haryanto

    user-pic A programmer (mostly Perl 5 nowadays). My CPAN ID: SHARYANTO. I'm sedusedan on perlmonks. My twitter is stevenharyanto (but I don't tweet much). Follow me on github: sharyanto.