October 2011 Archives

So, what's new from Perl?

A few weeks ago I read a discussion thread that mentioned Perl. It might be about Mojolicious 2.0 release, on reddit, my memory is failing me. A commenter asked about what novel projects that originated from the Perl community the past several years (like the last 3 years).

Perl used to be the source of ideas that get copied to other languages, e.g. DBI, WWW::Mechanize, and its regex flavor. Now the tide has turned, and although that is not a bad thing, one might wonder the same question.

It's true that for web development, many new ideas now…

Introducing Sub::Spec::HTTP::Server: Perl functions over HTTP, the dead easy way

Below is one way to serve function call requests (e.g. providing API service) using just one line.

Modules hitting CPAN mirrors as we speak (metacpan link: Sub::Spec::HTTP::Server):

# example module to export to HTTP, provides sprintfn()
$ cpanm Text::sprintfn

# module to do the magic, provides 'servepm'
$ cpanm Sub::Spec::HTTP::Server

$ servepm Text::sprintfn

$ wget -O- -q 'http://localhost:5000/api/Text::sprintfn?args:j=["Agent %(num)03d",{"num":7}]'…

Introducing Text::sprintfn

Hitting CPAN mirrors as we speak (metacpan link).

Just my approach of doing string formatting that supports named parameter. Instead of creating a new formatter (with a new/different syntax), I just extend sprintf a bit:

sprintfn "%d %(num)d %d", {num=>1}, 2, 3; # prints 2 1 3

Named parameter can also be used in the width and precision field:

sprintfn "%(num)(width).(prec)f", {num=>1, width=>1, prec=>4}; # prints 1.0000

Compared to oth…

Yet another stupid mistake #4

use Plack::Builder;

Instead of:

$app = builder { ... };

I wrote:

$app = sub { builder { ... } };

Now watch the weird errors you'll get if you do the same.

Perl module ideas #2

About the Perl Module Ideas posting series. Previous posts: #1.

* Archive::Manager (or Archive::Writer) using libarchive. There is now already Archive::Extract::Libarchive but a generic interface for writing would be nice too.

* Something to replace Log::Log4perl for my /users/steven_haryanto/2011/10/index.html

Perl module ideas #1

Below are some of module ideas that I think will be useful someday, but since it's not urgent now, I'm sparing my tuits elsewhere. There will be future posts.

* A module to detect the software of a forum (e.g. vBulletin, phpBB3, etc) and provide some basic API that works for all supported software, e.g.to retrieve threads and posts, open a new topic, reply to a topic, mark topics read, etc.

* Likewise for blog software.

* A module to detect {Yahoo Messenger IDs, Blackberry PIN numbers, street addresses, other contacts} from a text. I have written one for /users/steven_haryanto/2011/10/index.html

About Steven Haryanto

user-pic A programmer (mostly Perl 5 nowadays).