July 2014 Archives

(?P<NAME>...) vs (?<NAME>...)

Most Perl programmers using named captures in regex probably pick the (?<NAME>...) syntax, as that's what's displayed more prominently in the Perl documentation and tutorials.

However, Python does not support this syntax and uses (?P<NAME>...) instead (notice the extra P character). Incidentally, visual regex tool like kiki is built with Python and only support this syntax.

(?P<NAME>...) is also supported by Perl. So if you work with Python or use kiki, you might, like me, want to accustom yourself to using the P syntax.

PCRE (and thus PHP and other PCRE-using languages) supports both syntax. Komodo IDE's Rx toolkit support both. However, Ruby and .NET only support the non-P syntax. Well, that's how the real world works.

Easily add tab completion feature to your CLI program using Getopt::Long::Complete

There are several modules to help you create command-line program with tab completion feature, including Getopt::Complete and Perinci::CmdLine (and its new lightweight alternative Perinci::CmdLine::Lite. Now here's another one. Introducing Getopt::Long::Complete.

This module is a drop-in replacement for the venerable ="https://metacpan.org/pod/Ge…

Net:: vs WWW:: vs WebService::

(This blog post will serve as a document that I point to for people to read when I suggest people renaming their third-party-API modules [although not necessarily always from Net:: to WWW:: or WebService::]. I'm currently on a Questhub quest that does exactly this.)

Perl being a glue language, people write many modules to connect to third-party API services. These days, most public API services are web-based. What namespace should you pick for your module?


A lot of people still use /users/steven_haryanto/2014/07/index.html

Some statistics from Debian package tags

I'm running Debian Stable (7.x, Wheezy, 7.4 to be exact) on amd64.

Count all Debian packages by their implementation language (I know, not the most efficient way):

% ( for tag in `debtags tagcat | grep '^Tag: implemented-in::' | sed 's/^Tag: //'`; do
    echo -e `debtags search $tag | wc -l` "\t" $tag
  done ) | sort -nr
4439     implemented-in::c
3258     implemented-in::perl
1840     implemented-in::c++
1063     implemented-in::python
304      implemented-in::java
289      implemented-in::ruby
214      implemented-in::ocaml
199      implemented-in::lisp
194      implemente…

Benchmarking several ASCII-table-generator modules

UPDATE #1 2014-07-11: Added Catmandu::Exporter::Table. This module is not exactly lightweight, so I will not consider it for usage in Perinci::CmdLine::Lite, but it's interesting to benchmark anyway.

UPDATE #2 2014-07-11: Nudged by me, Jakob extracted the table-generating
functionality of Catmandu::Exporter::Table into its own module Text::MarkdownTable. This module depends on nothing but Moo. Great job Jakob. Although for my particular proje…

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.