Perl : Optimizing pattern searches with Regexp::Assemble

When you perform a pattern matching with multiple “or” (|) clauses, such as /pattern1|pattern2|pattern3/, Perl regexp engine will try to match each of them one after the other in sequence, resulting in poor performance if you have a long list of “or” clauses.

In order to optimize such a pattern matching, you can use the Regexp::Assemble module.

Continue reading Perl : Optimizing pattern searches with Regexp::Assemble

Scripting Twitter with Perl + LWP

A little follow up on yesterday article about scripting Twitter with cURL: the solution was working, but somehow inconvenient. Not practical to have to go and fetch the user id every time you want to send a direct message !

This time, I scripted Twitter direct message with Perl and LWP (libwww-perl), for a much more convenient solution. I designed it to be used like a sort of universal paging service.

Continue reading Scripting Twitter with Perl + LWP

Scripting Twitter with cURL

Twitter already provides an API but it is currently very limited. It will let you fairly easily change your status, but won’t let you send a direct message.

Comes in cURL. cURL is a very versatile command line utility which is designed to script web pages interactions. As a little demo, I’ll show you how to use it to easily overcome the shortcomings of Twitter’s API.

Continue reading Scripting Twitter with cURL

DocBook

Bored of fighting with MS-Word to have proper titles numbering ? Tired of messing around styles ? Want a more “meaning oriented formating” and less “aesthetic oriented formating” ? Would like to generate HTML, PDF, WindowsHelp, or anything from the same source file ?

Have a look at DocBook ! DocBook is a document standard which lets you do all of this, and much more …

And XMLMind XML Editor is a nice free (like beer not ideas) editor which lets you edit DocBook Documents in a WYSIWYG fashion.

Links :

DocBook : The Definitive Guide

XMLMind XML Editor

FreeBSD’s handbook (written in DocBook, and rendered as HTML)

Websites with Catalyst

If you like Perl and you make dynamic websites with databases backends, Catalyst is definitely worth a look.

It is basically an MVC engine for websites. It lets you nicely separate your business logic, the display and the database backend.

It has extended plugins to deal with things like authentications, sessions, templates, RSS, and God knows what 🙂

It can integrate Apache, and harness mod_cgi’s power for high-performance web applications.

It is a little bit tricky to get it right at the beginning, but there are nice tutorials.

Have a look ! 🙂

Main website you’ll find everything there

Deploying Perl apps

I usually code my perl programs on a development machine, and then ty to make in run in the production environment.

I used to manage by myself the various needed packages and tried to have them installed on the production environment as needed.

And one day I had to make a script run on a machine where Perl itself was not even installed…

This has been a nightmare until recently, that is to say until I discovered the PAR module. PAR is closed to the Java JAR files.

Once you have the PAR package installed, you have a set of helper scripts installed as well. Having you script run somewhere else is then as simple as :

pp -o app app.pl (you might want to do pp -o app.exe app.pl if you’re on Windows)

This script will analyze the script, gather all the dependencies (“all” including the Perl binary, used modules and DLLs), and build a self extractible archive which will unpack and execute your script when run.

Simple ? 🙂