Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

ethan (3163)

ethan ...

Being a 25-year old chap living in the western-most town of Germany. Stuying communication and information science and being a huge fan of XS-related things.

Journal of ethan (3163)

Wednesday November 17, 2004
01:38 AM

Busy again

It never ceases to amaze me how business is something that happens irregularly and unexpectedly. For a couple of weeks I didn't have anything particular to do programming-wise. That has changed this week. Eric J. Roode, author of the ill-named List::MoreUtil, apparently became aware of my List::MoreUtils (which was there before), and sent me a note that I should take the stuff out of his module and put it into mine. Similarly, I received a suggestino from Slaven Rezic to add a python-alike function zip. So now I have to translate both to XS.

Apart from that, I thought it might be useful to add a new language to my reportoir. Go's C# this time. It's really a very nice language. It's often compared to Java and has been titled a plagiarism which is entirely untrue. The only thing familiar from Java is it's sluggishness: You get a noticeable delay before a C# application would start. Runtime-wise however, it feels faster.

The good things about C#: It's convenient in that it has some syntactic sugar which makes the code less chatty than its Java equivalent. It hooks very tightly into the operating system so you can access all the things Java doesn't know about. With Java, I always had the impression that I am really programming a toy-machine and not a real one in that I may only do what the Java-API offers. To a certain exent, the same is true for C# only that this time I may do anything the operating system offers me. Also, it can be easily extended by embedding C/C++ code (I think the official lingo for that is 'unsafe code' which is entirely fine with me). And finally, you can use the familiar Windows widget-set and don't have to work with the Swing-cripple.

One remark about .NET: I simply can't understand why people hate it so much. It's really just a large API with the additional bonus that it is identical for C++, Visual Basic, C# and J# (whatever that is). Cunning as I am, I already came up with a useful pattern that can be deduced from that: Write your prototype in C# and once it's all working, translate to C++ which is a relatively smooth transition under .NET. Additional bonus is the fact that you're probably using Visual Studio. I am not much of an IDE guy in that I try to confine myself to vim and a couple of consoles but I have to say there's something quite appealing about that IDE in the way it can bundle source files in the various .NET languages, documentation, GUI design, Debugger etc. all together.

I also have a few rants, of course, but I save those for another entry a little later.

Sunday November 14, 2004
12:28 AM

The occasional bugreport rant

This morning I received:

Subject: Mail::Transport:Dbx
Date: Sat, 13 Nov 2004 20:07:06 -0500
Hi I use your program and i like it but I have found that when my .dbx file is
at a very large file size it does not work. So that may be a bug right?
thought you might like to know if you don't already.
xxxxx xxxxxxx

Well, no, I didn't know about it. Furthermore, I don't think I ever will with reports like that.

Even better, I don't seem to be able to reply. My mail just bounced. Interestingly enough though, the bounce mail gave me a different recipient address from the one that I sent it to. So there's probably a mail forwarding service out of control.

Wednesday November 10, 2004
12:53 PM

I love XP

Windows XP, that is. And no, I am not ashamed of admitting it.

The question is why I should be running XP in the first place. It had to do with my university taking part in Microsoft's MSDNAA program which makes most of their software available to academic circles. For the first time in my life, this gave me the chance to use a Microsoft product legally. So I copied the Windows XS Professional installation CD from a friend of mine who was so nice to have already downloaded it, got me a registration key and installed it.

It didn't go very well at first. XP was unable to talk to my DSL-router at all and it somehow made it block so that not even Debian could connect to it any longer without a prior restart of the router. Then, after XP was installed, WindowsME was gone. There was no way to tell lilo that there were WindowsME, XP and Debian on my two hard-disks. It turned out that the XP hard-disk partitioner insisted on creating the NTFS partition in a logical partition embedded in an extended one (ME was on the first partition of this disk and that was a primary one). So I screwed up the partitioning and and had to wipe out XP again.

After that, ME would still not boot. It was recognized by lilo again, but apparently XP made changes to the ME installation. Fortunately, I found an old ME bootdisk and was able to do a sys c: to fix things.

Now being smarter with partitions, I partitioned the ME-disk from Debian with cfdisk, making sure that this time I only had two primary partitions. Upon starting the XP installer, it did not accept the thusly created partition. I tried all kind of funny things to make it work, to no avail of course. I even managed to wipe out the MBR temporarily. I say temporarily because it re-apparead after a while. That must have happened when I was feverishly copying some data over to Debian from the ME partition because I was very sure I had destroyed the ME installation. Why it reapparead, I can't say. But I was relieved.

After a while, I figured out why XP refused to accept my partitions: I forgot to make a reboot after partitioning. I somehow assumed that repartitioning the disk and then starting the XP installer by booting from CD would register the new disk-layout. But apparently that was not the case. Anyway, after those annoyances, I installed XP again and this time was delighted to see that it had none of the previous problems with my router.

So why do I like XP so much? It seems to be a very well conceived system. Each and every bit of hardware in my machine was detected. I particularly loved it when I switched on my printer for the first time (a very old OKI laster-printer). It game me a plock-sound and a pop-up at the systray informing me that it detected and configured a new printer-device. And indeed it did. Lovely!

Also, the whole user-interface makes a lot more sense than the old ME/2000 style. It manages to hide away distracting information from me without sacrificing vital ones. It feels very lean and responsive even though one would assume that it's more bloated than previous Windows releases. Also, I feel reasonably safe even when using the Internet Explorer (which is due to the fact that I am behind a router and Microsoft's new firewall appear to work). Thanks to SP2, IE finally has a popup-block that works just as well as the one from Firefox that I got so familiar with.

There are only a few annoyances, mostly related to software-installations. I install as admin and most of the time the software has been properly set up for my user account, too. But some software fails in this respect. This is probably true for software that has been written with the old 98/ME setup in mind. It's not such a big problem, though.

Saturday October 23, 2004
01:11 AM

An 'unreportable' perl bug revisited

In my last entry I mumbled something about a tricky bug in perl that was allegedly unreportable. Good so because as it turned out, it wasn't a bug at all. I had this kind of setup:

    sub search {
    my ($self, $state) = @_;
    # $state->{last_search} being an array-ref of previous
    # search patterns. You were supposed to cycle through them
    # with TAB
    my $pattern = $self->get_input($state, $state->{last_search});
    # once a list of matchings songs has been returned and the user
    # chose one of them to play
    sub get_input {
    my ($self, $state, $searches) = @_;
    if ($hit_key == KEY_TAB) {
        push @$searches, shift @$searches;
        goto &search;
    return $search_pattern;

The above is naturally just a simplification. There are several event-loops going on at once so I kind of had to chose such an awkward way. Now the thing is that goto &func replaces the running instance of a function with &func. When looking at search() it becomes obvious that this would eventually expand to:

    my $pattern = $self->search($state);

which is wrong as now $pattern would contain the return value of search which would be its last value evaluated ($state->playlist->play always returns 1). Now I changed things so that get_input does a goto &get_input instead.

So far I always thought that goto &func would be one of those less harmful things. But in fact, it's even worse than anything Dijkstra described in his pamphlet.

Thursday October 21, 2004
12:04 AM

An 'unreportable' perl bug

Over the last two days I was chasing a bug in my re-written mp3-player. Eventually with the help of Carp::confess I was able to see what was going on: A method received an additional argument although this was impossible. The line that confess included in its stacktrace was this:

    my $pattern = $self->get_input($state, $compl ? $compl : $state->search);

This call, according to confess, resulted in ActionLoop::search(ActionLoop=HASH(0x814cbb8), 1). I wonder under which contrived circumstances $obj->method can produce an additional argument. $state->search() did not fix it. The only way was passing undef explicitely.

Unfortunately, there's no obvious way for me to report this bug as the bigger picture includes three methods of which one calls the other sort of tail-recursively using goto &func. I am very sure that the bug immediately disappears when I try to strip it down enough to include it in a bug report.

On an entirely different front, I polished up my freshly installed Debian a little. I can finally watch TV. It turned out that these deadlocks were produced by an apparently buggy Nvidia driver. Using an older one fixed it. The amazing thing is that my whole Debian partition is only filled with 1.3GB of data and it can do everything that my Linux from scratch could do with 26GB. As a result, it's blazingly fast even though Debian comes with no packages that were compiled with the optimization settings that I used for Linux from scratch. Even the default perl (which is an ithreaded one) feels quicker than the non-threaded Linux-from-scratch-counterpart.

Wednesday October 20, 2004
12:11 AM

Back to Debian

Ever since the smaller of my two hard-disks went up in smoke, I had a new hard-disk and installing a new Linux rather high on my to-do list. Both is now done.

As for a hard-drive, I got one of those nice Seagate Barracudas. Speed-wise they are only avergage, but you can hardly hear them operate which is a huge progress if you compare that to my other drive (a Maxtor one).

Installing linux unfortunately became a neccessity, too. The setup I've been using so far was a Linux-from-Scratch. I have to admit that it worked splendidly well but the fact that I needed to compile everything by hand and that upgrading any packages is virtually impossible made it impracticle on the long run. But as I did like the idea of having a lean system that was specifically compiled for my machine, I installed Gentoo over the weekend. At first it went all fine. It was a snap to make a network install over DSL.

But yesterday it became apparent that many things aren't that bright at all. It was impossible to get my precious mp3-player working. It's a bit heavy on dependencies in that it requires MPEG::MP3Play, Ogg::Vorbis::Decoder, Ogg::Vorbis::Header, MP3::Info, some terminal related modules and a piece of Inline::C I wrote around libao. Second bad thing about gentoo is xawtv: Depending on which version I installed, it either segfaulted right on start-up or it merely produced a blue screen. I was able to get it working without Xvideo support but that meant I couldn't make it run fullscreen at a higher resolution without black areas around the screen. Thirdly, Gentoo makes it virtually impossible to set up mail properly. It does offer the various MTAs such as sendmail, postfix or exim. But apparently I need to configure it myself. For exim, this would be fine if it was exim3, but they only have exim4 which I was never able to get running. Their suggestion of using nbsmtp will prevent my newsreader slrn from installing as it requires a proper sendmail binary. So that is inacceptable as well.

So eventually I turned back to Debian which I had used happily for years (until this hard-disk was nuked). Installation wasn't quite as nice as the minimal installer image does allow you to install it over modem but strangely enough not over DSL. Some manual interventions were therefore necessary. Another thing that I hated was the bootloader. By default it tries to install grub. After telling me that it detected two more bootable partitions (windows, linux from scratch) and ensuring that it could easily integrate those into the MBR, I hit 'yes' and upon reboot ended up with error message 18 or so. I knew this was would happen. One reason why I always stick with lilo is that I know it works.

After a while those initial anoyances were cleared. Everything's now up and running (including exim even though it's exim4 but Debian kindly offered to configure it for me). There's one thing that's still troubling me: xawtv does work but it will lock up the machine after a few minutes. And with lock-up I really mean lock-up. Not even Magic SysRq will work any longer. Things like that, I am sure, will be notoriously hard to fix with no helpful logfile entries whatsoever. But apart from that, my old opinion stands: Debian isn't quite as flashy and hip as other distributions, but it's always the one that reliably works.

Sunday October 10, 2004
12:34 AM

ogg-vorbis stinks

I have to say that pretty much everything about ogg-vorbis files and streams stinks as far as Perl modules are concerned. For years, I've been using my own mp3-player backed up by the wonderful MPEG::MP3Play module. Unfortunately, the player itself was written in a dreadful way which made extending it impossible.

Now it happened that I got hold on a few .ogg files that I would have liked to add to my playlist and, naturally, play them as if they were ordinary mp3s. Due to the inextensibility of my player that wasn't so easy at which point I decided to rewrite it. A song becomes a class and there's now on subclass for each filetype.

And then disaster set in for me finding a suitable module for decoding and playing back ogg-vorbis files. There's Ogg::Vorbis which only allows to read PCM streams. That would be fine in its own right and I immedately added an Inline::C-section that opened /dev/dsp and configured it accordingly to play PCM streams with 2 channels, 16 bits and 44100 Hz. That didn't work and I still can't say why. Also, I noticed that Ogg::Vorbis doesn't provide methods for reporting the position of the current bitstream so with this modules it's impossible to have a counter of the playing time for each song.

Then I found Ogg::Vorbis::Decoder which doesn't suffer from those limitations. Also, it actually comes with proper documentation. Yet, it still didn't work together with my Inline::C code. So I had to try two other modules, bother wrappers around libao. The first one (Ao) didn't even compile as it was evidently written for a very old version of libao. The other one (Audio::Ao) did compile and passed its tests. Even better, it worked for me at first.

Then I looked for OGG-tagging modules. Ogg::Vorbis::Header was the one I tried first. Didn't work although it passed its own tests. I found out that the reason was a strange interaction with Audio::Ao. Both are Inline::C modules and I received many "One or more DATA sections were not processed by Inline". Apparently it's not trivial to use two such modules at the same time. I had to get rid of one of those two modules and I tried Ogg::Vorbis::Header::PurePerl. Now my player worked again and was capable of displaying the tags. But I couldn't edit them as Ogg::Vorbis::Header::PurePerl gives read-only access only.

The solution I eventually came up is clunky: I copied the Inline-code of Audio::Ao into my OGG-class and added a Inline->init right next to it. It's those kind of work-arounds that just confirm my hatred of anything Inline-related.

Now, compare that to mp3-handling in Perl: I only need two modules: One for the tag (MP3::Info in my case) and one that can play them back (MPEG::MP3Play). The latter gives me a unified event-API that reports timecode, supports pausing playback, adjusting the volume, comes with an equalizer etc. And of course it's written in proper XS so it's guaranteed to work immediately.

Thursday September 02, 2004
11:59 PM


For the next six weeks I'll be interning for Grünenthal, a German pharmaceutical company (they have gained some infame in the late 1950s due to the Contergan (Thalidomid) affair which left many newly born babies with crippled limbs). I'll be working in their communication department which is the place to be if one wants to learn quickly how companies of that size function.

The only drawback is that my work wont involve a lot of computers. Other than that, it's splendid. There are four nice female colleagues and one other chap who's currently on holidays. What I have to get used to, though, is the working hours: It's from 8.30 in the morning to around 6 in the evening, plus two hours of public transport for me. Incidentally, I received quite a few more mails this week than usual concerning my CPAN modules which I now have to leave pending till the weekends.

Sunday August 08, 2004
03:18 AM

Looking for a new occupation

Every once in a while I reach a stage where most of my on-going work is done, such as all or at least most of the modules I am working on are released to the CPAN etc. It is then that I am seeking for something new and while doing so I am trying all different kind of things.

This happens in an unstructured way. A while ago I was talking with a fellow about some stuff, mostly computer games, and we agreed that it would be sort of cool to write ones' own. Since I've never done anything like that, I had a poke around at several available libraries and ended up having a closer look at the SDL. It's less complex than I thought, but I lack quite a bit of background knowledge on some apparently vital stuff, mostly involving image processing and such.

So I made a mental note to return to this domain later and moved on. The next item on my to-try list was writing a module for the Linux kernel. I had in mind a simple module that allowed to mount audio CDs as ordinary file-systems and thus see the tracks of the CDs as virtual WAV files that spring into existance once I copy them onto a harddisc partition (grabbing by doing a cp). I'm sure that this would be an entertaining thing to program, but during my first attempts I realized that it's exceptionally easy to freeze the whole system. I had a few of those lock-ups and concluded that programming with reboots every three minutes is less fun than programming without reboots.

So I returned to the SDL. Quite soon I reached a point where things - albeit mostly working - got annoying because they required a lot of code. Those are things that should not, in my estimation, require that much work. Rescanning other libraries revealed that some of them offer a slightly more high-level functionality, for example the clanlib which looks quite promising. Only drawback is that this it's a C++ and not a C library.

Since I've wanted to improve on my C++ skills for a long time anyway, I decided to start all over again, this time doing it in C++, with the prospect in mind, that thusly I can switch to the clanlib a little later. Now I am already regretting that I postponed my C++ experience for such a long time. It's all very nice and smooth. In particular, it's much easier to keep the program relatively tidy thanks to classes and namespaces. In C, most of the time is spent on coming up with a clever naming scheme in order to avoid name clashes and such. I'm glad that this is now something I have to worry about much less.

Friday July 09, 2004
04:13 PM

Having fun with

Hmmh, let's see. A while ago, Randal L. Schwartz gave one-star ratings to all modules by Domizio Demichelis due to a rather questionable practice in all their Makefile.PLs. Now their author seems to have launched a counter-attack, by having two people (Massimiliano Ciancio and Carlos Molina Garcia, two Italian sounding names, go figure) give all of his modules five stars.

I am now almost tempted to create a couple of alter egos which will downgrade his modules. Might be fun to see new Italian CPAN raters spring into existance after that to hand out five-star ratings to these modules again.

Really very tempting, if it just wasn't so childish.