Aug 29 2015

Trigonometry cheat sheet

Tag: Linux,Perl,WIPgoeszen @ 8:22 pm

This is a rather amateurish Perl cheat sheet for when you're starting with trigonometry in Perl. First, Perl uses radians instead of degrees, so you'll have to use Math::Trig's rad2deg and deg2rad functions to computer the one or the other, compare Perl Cookbook, ~ chapter 2. Then you might want to calculate the arcsin of […]


Sep 03 2012

Portable SQL for development between SQLite and MySQL

Tag: Linux,Perlgoeszen @ 9:04 pm

In case you are developing web applications in Dancer or similar "first local then online" frameworks one common setup is to use SQLite when you run your app local in development mode, and then you take it online into the production environment where it utilises a MySQL server for the database work. One thing is […]


Sep 03 2012

SQLite throws an error on SQL with REGEXP

Tag: Linux,Perlgoeszen @ 8:34 pm

While developing a Dancer application recently, I started using SQL sentences with a REGEXP filter in them. Which resulted in a strange error... As I found out, SQLite's implementation of the REGEXP function is quite incomplete. Solution for now: Make sure you've got a properly updated DBD::SQLite driver for your DBI. Newer versions have a […]


Mar 25 2012

Dancer default directory layout

Tag: Linux,Perlgoeszen @ 7:50 pm

As a personal reminder, here's the dir layout or directory structure Dancer implicitly recommends by making it what the "make application" switch generates: $ cpan Dancer # or cpanp, or cpanm $ dancer -a MyApp Dancer version ?: + ./MyApp + MyApp/views + MyApp/views/index.tt + MyApp/views/layouts + MyApp/views/layouts/main.tt + MyApp/environments + MyApp/environments/development.yml + MyApp/environments/production.yml + […]


Mar 19 2012

Generating XML sitemaps with XML::Twig::Elt

Tag: Linux,Perltengo @ 2:06 pm

The sitemaps protocol (help at Google, official homepage sitemaps.org) as proposed by Google is gaining wider popularity. When you are running a site and want good visibility in search engines, you surely want to have it crawled regularly and completely. One stepstone into that direction is to serve your content in the form of a […]


Jan 22 2012

Generate a unique ID for your image scans, with Data::Uniqid

Tag: Linux,Perltengo @ 9:46 am

When I scan images, or paper notes, I like to leave a short note on the document I scanned referrring to my scanned digital copy of it. For example, when I scanned an image, I note on the back of it that this one is already scanned and I don't have to rescan it over […]


Jan 15 2012

RegEx to match YouTube IDs

Tag: Linux,Perltengo @ 5:25 am

This regular expression here can be used to match YouTube IDs: $youtube_url =~ /watch\?v=([\w-]{11})/; In words: \w: match any alphanumeric chars including _ (the dash), means letters, numbers; also match - (the minus); match eleven chars.It ignores further url query parameters.


Aug 12 2010

Show current version of an installed cpan module

Tag: Linux,Perltengo @ 3:58 am

Often, you may ask yourself what version of a specific perl cpan module you've got installed on your system. So here is how to find out what version a perl module is, as an example on CGI.pm: perl -e 'use CGI; print $CGI::VERSION."\n"'


Mar 03 2010

WxPerl: Converting images for use as embedded XPM in your Perl code

Tag: Linux,Perltengo @ 5:51 am

Writing applications in Perl with WxPerl for GUI layout is nice. Decorating your apps with images is even nicer. Now when you go the extra mile to package your apps as compiled binaries, it can be regarded as messy to have the used images as external dependencies outside your code. One solution around this is […]


Nov 25 2009

Resolving a “print() on closed filehandle” error

Tag: Linux,Perltengo @ 9:50 am

Today I banged my head for a few minutes against a strange error: I got a print() on closed filehandle from a simple code passage: open(my $out,">>", "/some/file") or die "File error: $!"; print $out "sometext\n". close($out); Can you spot the error? After reading through two good help threads here and here, I came to […]


Mar 19 2009

Crypt:SSLeay install problem under StrawberryPerl

Tag: Linux,Perltengo @ 11:50 am

A minute ago I had problems running the cpan install of Crypt::SSLeay under Windows + StrawberryPerl: cpan -i Crypt::SSLeay Before I tried the cpan module install I downloaded and installed openssl and Microsoft Visual C++ 2008 Redistributable Package. When cpan asked me where I installed openssl I pointed it to the right directory, but still […]


Mar 16 2009

How to feed query string values to a script on command line

Tag: Linux,Perltengo @ 8:03 am

Often while debugging nasty "500 Internal Server Errors" and when everything seems to work on command line but the webserver refuses to properly serve your script's output (btw: check if you set permissions right, twice!) you might want to feed the query_string to a script on command line. Running a script in default mode, without […]


Mar 12 2009

CPAN and Wx on StrawberryPerl, problems resolved

Tag: Linux,Perltengo @ 4:43 pm

Shortly after learning about StrawberryPerl (which I documented in my post about it as replacement for ActivePerl) I was tempted to actually try it. Well, tempted..., more like forced to try it. A script I am developing needed HTTP::Proxy and I was just unable to fetch it/get it working in the ActivePerl environment - even […]


Mar 03 2009

Simple mbox eMail reader in Perl

Tag: Linux,Perltengo @ 7:56 am

Although the email protocol (RFC2822) is one of the oldest of all the "Internet protocols", getting perl to handle it is actually not that simple at first. Heading over to cpan it took me some minutes and a prototype script to get it do what I thought would be a one-liner. My scenario was that […]


Feb 27 2009

Wx::Perl lessons learned

Tag: Linux,Perltengo @ 1:04 pm

WxPerl (Wx::App on cpan) is a great tool to design visually rich graphical user interfaces for your scripts. But the downside is that the learning curve is quite steep. There were many incident when I was banging my head against the wall for hours until I finally got what I intended. This post is meant […]


Feb 27 2009

StrawberryPerl, the ActivePerl alternative

Tag: Linux,Perltengo @ 11:03 am

Windows and Perl - that's quite a story. For a number of years now I've been using ActivePerl, not without encountering some problems along the way. One of the most annoying is that ActivePerl relies on ppm packages to install modules, not the original CPAN modules. So it takes some time until ppm versions of […]


Jan 25 2009

Search engine crawler design references

Tag: Linux,Perltengo @ 10:05 am

When starting the coding/design of a new search engine crawler (a challenging task, read What I've learned from writing a large scale search engine), some input from people who've been there and done that might be quite helpful. Of course, there is the original Google paper and some other stuff around that I like to […]


Jul 20 2008

Compile a perl script that uses Wx with pp and PAR

Tag: Linux,Perltengo @ 9:30 am

Compiling scripts with pp, PAR's helper script, to executable binaries (.exe files on Win32) should be a pretty straightforward process. Anyway, if you are developing GUI applications, probably with Wx, you will surely run into some problems. Upon execution, the generated execs will complain about missing libraries, DLLs or similar. This is because pp does […]


Jul 03 2008

Installing WxWidgets on 64 bit Ubuntu

Tag: Linux,Perltengo @ 5:25 am

Getting a working version of Wx and wxperl running on a amd64 Ubuntu system (mine was 6.06 dapper) can be a bit tricky. Everytime I tried to install Wx via cpan the Alien::wxwidgets module complained and refused to install this required package for Wx. The problem seemed be that I had no version of Wx […]


Jun 21 2008

Shorthand if-clause

Tag: Linux,Perltengo @ 7:10 am

There is a handy short version for a classic if-else-statement that is very useful, but everytime I'd like to use it, I just can't fully remember what its syntax was. And looking it up on google is hard, because "if" is a very common word... It is especially useful on initializing variables in a cgi […]


Jun 17 2008

Working with very large hashes

Tag: Linux,Perltengo @ 10:59 am

Recently, I had to wrangle a large dataset, with over 3 million key-value pairs. I needed to iterate over them in a sorted way and I needed the hash-structure to weed out "already-seen-keys". My first approach was to build a hash in memory, with the usual my %hash, then adding keys and values in a […]


Jun 01 2008

How to format a string with leading zeros?

Tag: Linux,Perltengo @ 9:09 am

A quick reminder: How do I pad a string so that a number or string gets leading zeros? Answer: By using sprintf: my $number = 123; $number = sprintf("%07d", $number); print $number; Output: "0000123" after the %: "0" is the character to add, <number>d is the amount of digits (that's why it's "d") to add. […]


May 28 2008

SQL select from two tables with the same field name

Tag: Linux,Perltengo @ 9:15 am

Running MySQL and doing join'ed queries you might run into problems when you try to get results from two tables into one results set, where both tables have a field that is identically named (common with id-fields). For example: SELECT table1.id, table1.fieldA, table1.fieldB, table2.id, table2.fieldC, table2.fieldD FROM `table1`,`table2` WHERE table1.fieldA = 'test' AND table1.id = […]


Mar 26 2008

What I’ve learned from writing a large scale search engine

Tag: Linux,Perltengo @ 3:09 pm

Writing a large-scale web-crawling and web-indexing search engine from scratch is a large beast to tame and in many cases a project that is heading for desaster right from the start. As you can read in Alex's worklog for the ongoing effort to manage the Majestic-12 distributed search engine, writing a crawler alone can cost […]


Mar 20 2008

What it is all about

Tag: Linux,Perltengo @ 3:11 am

In this blog, I'd like to publish trick, tips and hints related to the scripting/programming language Perl, which should not be confused with PEARL. Although the origin of the name Perl are a more adventurous story, today most agree that Perl stands for Practical Extraction and Report Language, which summarises quite well what it does […]


Mar 20 2008

Compile your own perl in a custom directory

Tag: Linux,Perltengo @ 2:58 am

This procedure is useful when your shared hosting webserver is running an outdated version of perl but your applications need a newer version; for example when utf8 functionality is needed which only newer versions fully support. First read this small paragraph: http://www.bugzilla.org/docs/2.22/html/nonroot.html Then get the latest perl sources and extract/configure/compile it: $ wget http://perl.com/CPAN/src/stable.tar.gz $ […]