Today my ISP lost all routing for 10 hours. How charming. While I was disconnected from the net and had nothing better to do, I sat down and did a long-delayed rewrite of alien. This is alien's 4th rewrite, as it has progressed from shell script, to crummy perl code, to perl code that at least used strict and modules properly, and now to fully object oriented perl code. At least alien has managed to get better with each rewrite, and this time is going to be no exception.

Anyway, I'm very pleased with how it works now. A simplistic alien can be written in a single long line of perl, like this:

perl -MAlien::Package::Deb -MAlien::Package::Rpm -e '
    $p=Alien::Package::Rpm->new(filename => shift); $p->unpack;
    bless($p, "Alien::Package::Deb"); $p->prep; $p->build'

The really neat bit is that alien is now just a bunch of objects that represent packages of a given format, and are capable of rebuilding those packages. If an object is blessed into another format, it retains all the metadata from the original package, but becomes able to write it out in the new format. All the (very) messy conversion happens behind the scenes.

I'm not sure what to call this object oriented technique. Does anyone know of a fancy name for the techinque of dynamically changing an object's type? Is this even possible in languages other than perl?