All development related posts
All development related posts
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.
The following step-by-step will let you create a user, a database (DB) and grant full access to the user to this DB.
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.
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.
There are many reasons you might want to dump your SVN repository to a flat file : for example to simplify backup operation, to transfer to another server, or to convert your repository from FSFS to BDB or the opposite.
I’ve written 2 sample applications to demonstrate how easy it is to use the API v2 of Google Maps.
I was honnestly surprised to see how easy it actually is… Have a look at the source of the pages and see for yourself
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
FreeBSD’s handbook (written in DocBook, and rendered as HTML)
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
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 ?
If you want to convert strings from, say, UTF-8 to Latin1, then you can do this as simply as this :
use Unicode::String qw(utf8);
print utf8(“string in utf-8″)->latin1
Easy ?