Perl

TOP

DESTROY or __DIE__ - choose one

Some people always complain, even about the language they've been working with for years while they has other options. One of them recently complained that Perl cleans up objects in unpredictable order during global destruction (after exit; and all END blocks). Here is what happend, how we tracked it down and solved it.
Weiterlesen
TOP

Compressing test for short strings

Data is getting bigger and bigger as technology advances. We didn't even think about using something inefficent like XML when I started writing sourcecode on a Datapoint 6600 or even in MS-DOS world, but today? A meg more or less doesn't matter today. But sometimes space is still premium and so it is for my current project. I'm working with short strings (text plus some extra chars, about 6 bit  per char) and they should be compressed.
Weiterlesen
TOP

The truth about DBD::mysql's bind values

SQL has some drawbacks, the worst one might be the SQL injection chance. There are many ways to avoid them but few of them are really working, one of them is using bind values by replacing all values by ? and passing the real values at execution time.
Weiterlesen
TOP

mySQL left the party (2006 'MySQL server has gone away')

mySQL servers have their own mind and sometimes just disappear. They go away from a client leaving it alone if the complete server is dying, if a client is doing unexpected things and sometimes even without any known reason.
Weiterlesen
TOP

Using Memcache as database locking helper

Race conditions are nice: Two (or more) tasks are fighting for the same thing at the same time. Row locking on the database may help to avoid such races but only if the database supports them.
Weiterlesen
TOP

Parse both GET and POST data in the same request using CGI::Simple

The Perl CGI module is commonly used, but it's heavy. CGI::Simple is more lightweight but lacks some features. Here is a feature not supported by CGI but by CGI::Simple.
Weiterlesen
TOP

Setting up Gearman

I recently announced an article about Gearman, today I'ld like to start with setting up a Gearman dispatcher server.
Weiterlesen
TOP

Web-Multitasking: Whos gonna work for the working man?

Web scripts usually do one thing at a time which is quite good as long as there is not too much to do. But serving thousands of request per minute with thousands of source code lines per request starts getting challenging. Bon Jovi asked for help for web scripts some time ago by writing his song "(Whos gonna) work for the working man". Well, there are little chances that he had something else in mind, but who cares.
Weiterlesen
TOP

Don't use exec and database connections

Typical Perl scripts (and others running as CGI-scripts) run and exit once they're done, but this isn't very efficient with medium or high request counts. Persistent solutions like FCGI and ModPerl avoid the additional interpreter loading and compiling phases, but start being challenging if any source file is changed.
Weiterlesen
TOP

Order your checks

Doing many checks may slow down a program, but sorting the tests may improve your program's speed a lot at a very low cost.
Weiterlesen
TOP

Creating a crossword puzzle

Actually not a 100% real one, but something near by, like this one (near the end of the text).

Crossword puzzle creators must know and remember many words, but everybody could create one with a little help by a computer.

Weiterlesen
TOP

SQL injection 2.0: Regular Expression injection

SQL injections are well-known and could easily be used against against most PHP scripts, but there is a much easier injection leak in many Perl scripts: Regular Expression injection.
Weiterlesen
TOP

Counting letters in Perl

A blog comment resulting in a new post? Yes, a guy from southern Germany made me do this by trying to use the whole alphabet in his comment.
Weiterlesen
TOP

Writing a DBI database driver

DBI is the universal Perl database interface but it's using a so-called DBD driver module for each database type. I've been searching but didn't find a DBD module fitting my needs and so I started writing a new one.
Weiterlesen
TOP

Capture STDOUT and STDERR of external command

IO::CaptureOutput is a great module but provides limited control. Here is a quick hack to replace the capture_exec function while getting more control about what is being done.
Weiterlesen