Perl

TOP

Perl Taint mode: Vergiftete Daten

(SQL) Injection ist immer wieder für Bugs gut, vor allem bei Webanwendungen, aber auch andere Stellen können ganz leicht sehr gefährlich werden. PHP hat das lange Zeit in eindrucksvoller Weise demonstriert - dazu reichte schon ein sehr simples index.php:

Weiterlesen
TOP

Perl grep, map und ()

map und grep sind zwei sehr mächtige Perl-Befehle: Richtig eingesetzt ersparen sie so manche überflüssige Programmzeile und zusätzlichen Speicherbedarf. Mit Hilfe zweier unscheinbarer Klammern kann map um die Funktion von grep erweitert werden.

Weiterlesen
TOP

Data::ObjectDriver and JOIN

Data::ObjectDriver is a great ORM. It's easy to configure and easy to use, but not as powerful as DBIx::Class (which isn't that easy to learn and I actually prefer using a wrapper instead of "native" DBIx::Class, but that's another story). There is one major thing I missed with Data::ObjectDriver: JOINing foreign tables.

Weiterlesen
TOP

More Perl variable & block secrets

I wrote about Perl variable declaration secrets recently, but there's much more. Perl has a very simple way for passing variables to subs which should be called later.

Weiterlesen
TOP

Perl variable declaration secrets

Perl has a very flexible variable concept. One might use different namespaces, called "packages" or use all variables global without defining them. Another way to use variables is more Cish where every single variable must be declared before it's used.

Weiterlesen
TOP

Parallel DNS lookups using AnyEvent

Perl has a great asynchronous library: AnyEvent. (There may be even more great asynchronous libraries, but it decided to use AnyEvent.) I recently had to lookup a lot of different hostnames and didn't want to do it sequentially (because every single DNS server might be down or wait until the reply is received).

Weiterlesen
TOP

Perl -M-A-C tests

Perl supports various tests for file and directory states. Most are identical to their bash test siblings, but some additional are supported, like -M, -A and -C.

Weiterlesen
TOP

Setting up DKIM email signatures with Perl

DKIM may be called as PGP successor: PGP has been used by many people for signing their emails at a time when mostly technical related people had been using the internet. Today, few people still use PGP to sign their emails, but email servers took over this part using a technology called DKIM.

Weiterlesen
TOP

The five faces of a Perl hash item

PHP calls it associative array, JavaScript calls it object and - in the eyes of other (older) languages like C, BASIC, Pascal or Perl - all of them are wrong. An array has some items which may be addressed using their position in the list, but only a Perl hash has named keys. A hash is basically an (unordered) list of items where each item has a key and a value - but that value may have one of many different states.

Weiterlesen
TOP

Digest::SHA1 Workaround

MovableType is still using the old, deprecated Digest::SHA1 module in some versions. Using the newer Digest::SHA is recommended and MT will switch in future versions, but Digest::SHA1 is currently still required for commentor logins in some versions.

Weiterlesen
TOP

Cookie __atrfs and CGI::PSGI problems

Some websites stopped working today or at least some cookie-based functions ran out-of-order. Deleting all cookies helps - but is no solution. A cookie called __atrfs set by the famous AddThis! service is responsible for this.

Weiterlesen
TOP

Remote debugging Perl scripts without SSH access

I'm used to use dedicated or at least virtual servers for projects, but currently, I'm working on two projects which are using simple webspace instead without SSH access. A cgi-bin directory is all you need for Perl, but what happens, if a script dies without an error message?
Weiterlesen
TOP

Retry failed Gearman jobs

Gearman is a great tool for farmed or distributed work. It's some kind of basic cloud handling: Many Worker processes (usually running on many different servers) are waiting for jobs to process and there's (hopefully) always another worker taking over if one worker (server) should ever die. But what happens, if a single job dies and should be repeated?
Weiterlesen
TOP

Quick JSON pretty reformatter / JSON-tidy

JSON is a commonly used format for data transmission, especially with Ajax calls. It's more structured and easier to process then XML, but could be just a wall of text depending on the creator. This oneliner reformats JSON to look pretty and human-readable.
Weiterlesen
TOP

Moose documentation quick reference

I don't like Moose. It has a lot of disadvantages and tries to create a new language based on Perl - without any need. But I'm forced to use it within a project and working myself into all that stuff, the documentation turned out to be as bad as the one of DBIx::Class. This post is my attempt to merge the most important documentation parts.
Weiterlesen