Perl: dodo you unondoderorsostotanondod tothohe rorobobboberor lolanongoguagoge

As kids, most Scandinavians, get introduced to a language called "røverspråk" (in Norwegian) or the robber language.

Before tonight, I was unaware that this language was due to the books about Kalle Blomkvist (I have never read them) by Astrid Lindgren, but with the help of Mr Google, I found what I needed at Wikipedia :)

The reason for all this, was quite simple; I was playing around with an old translator I had written in Perl some years ago. I had not used map{}, so I quickly rewrote it as a oneliner:

$ perl -wle 'print join(" ", map{s/([bcdfghjklmnpqrstvwxz])/$1o$1/g;$_}@ARGV);' hello

This is a crude version, that does not translate upper case characters.

A version doing this is a bit "long" for a oneliner, but for the fun of it I will present it anyway:

$ perl -wle 'print join(" ", map{s/([bcdfghjklmnpqrstvwxz])/$1o$1/g;s/([BCDFGHJKLMNPQRSTVWXZ])/sprintf "%so%s",$1,lc($1)/ge;$_}@ARGV);' My name is Rune
Momy nonamome isos Rorunone

An untranslater is about the same amount of work:

$ perl -wle 'print join(" ", map{s/([bcdfghjklmnpqrstvwxz])o\1/$1/gi;$_}@ARGV);' Tothohe rorobobboberor lolanongoguagoge!
The robber language!

1 comment:

  1. Perl is the best scripting language for Text processing and handle regex. I have posted few articles related to those at my blog


    Also Perl's Cpan has lots of support that I don't even need to think extra while developing project. I didn't find such help on other programming language except Java and .NET