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 ]

Shlomi Fish (918)

Shlomi Fish
AOL IM: ShlomiFish (Add Buddy, Send Message)
Yahoo! ID: shlomif2 (Add User, Send Message)

I'm a hacker of Perl, C, Shell, and occasionally other languages. Perl is my favourite language by far. I'm a member of the Israeli Perl Mongers, and contribute to and advocate open-source technologies. Technorati Profile []

Journal of Shlomi Fish (918)

Saturday August 09, 2008
06:25 AM

make test in maintperl-5.8.x Fails on Linux

Due to the fact that my email to perl5-porters bounced for some reason, and because the email I filed using perlbug was not registered in the bugtracker for some reason, I'm posting it here:

It seems that on Mandriva Linux Cooker (the Mandriva bleeding edge
distribution) on maint-perl IPC::SysV fails "make test":

Failed 4 tests out of 1095, 99.63% okay.
### Since not all tests were successful, you may want to run some of
### them individually and examine any diagnostic messages they produce.
### See the INSTALL document's section on "make test".
### You have a good chance to get more information by running
###   ./perl harness
### in the 't' directory since most (>=80%) of the tests succeeded.
### You may have to set your dynamic library search path,
### LD_LIBRARY_PATH, to point to the build directory:
###   setenv LD_LIBRARY_PATH `pwd`:$LD_LIBRARY_PATH; cd t; ./perl harness
t; ./perl harness
###   export LD_LIBRARY_PATH=`pwd`:$LD_LIBRARY_PATH; cd t; ./perl harness
### for csh-style shells, like tcsh; or for traditional/modern
### Bourne-style shells, like bash, ksh, and zsh, respectively.
u=5.17  s=1.62  cu=359.73  cs=35.41  scripts=1095  tests=132095
make[2]: *** [_test_tty] Error 1
make[2]: Leaving directory
`/home/shlomi/Download/unpack/perl/perl5/maint-perl/perl-5.8.x-121819 0282'
make[1]: *** [_test] Error 2
make[1]: Leaving directory
`/home/shlomi/Download/unpack/perl/perl5/maint-perl/perl-5.8.x-121819 0282'
make: *** [test] Error 2

I noticed it was the only upgrade since I updated perl-5.8.x-latest. I'll try
to investigate further.


        Shlomi Fish

[Please do not change anything below this line]
F lags:
Site configuration information for perl v5.8.8:

Configured by shlomi at Fri Aug  8 13:14:33 IDT 2008.

Summary of my perl5 (revision 5 version 8 subversion 8 patch 34096) configuration:
    osname=linux, osvers=2.6.26-desktop-2mnb, archname=i686-linux
    uname='linux 2.6.26-desktop-2mnb #1 smp wed jul 23 11:32:46 brt 2008 i686 intel(r) pentium(r) 4 cpu 2.40ghz gnulinux '
    config_args='-de -Dprefix=/home/shlomi/apps/perl/perl-5.8.x-latest -Doptimize=-g'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
    cc='cc', ccflags ='-DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    cppflags='-DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include -I/usr/include/gdbm'
    ccversion='', gccversion='4.3.1 20080626 (prerelease)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /usr/lib64
    libs=-lnsl -lndbm -lgdbm -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -g -L/usr/local/lib'

Locally applied patches:

@INC for perl v5.8.8:

Environment for perl v5.8.8:
    LOGDIR (unset)
    PATH=/usr/java/jdk1.5.0_09/bin:/home/shlomi/Download/unpack/graphics/fop/fop-0.9 3:/home/shlomi/apps/perl/modules/local/bin:/home/shlomi/apps/latemp/bin:/home/sh lomi/apps/file/gringotts/bin:/home/shlomi/apps/gimageview/bin:/home/shlomi/apps/ test/quadpres/bin:/home/shlomi/apps/docbook-builder/local/bin:/home/shlomi/bin:/ usr/local/bin:/bin:/usr/bin:/usr/games:/usr/lib/qt4/bin:/usr/bin:/opt/kde3/bin:/ usr/lib/ssh:/usr/lib/qt4/bin:/usr/bin:/opt/kde3/bin
    PERL5LIB=/home/shlomi/apps/perl/modules/lib/perl5/site_perl/5.10.0:/home/shlomi/ apps/perl/modules/lib/perl5/site_perl/5.8.8:/home/shlomi/apps/perl/modules/lib/s ite_perl/5.10.0:/home/shlomi/apps/perl/modules/lib/site_perl/5.8.8:/home/shlomi/ apps/perl/modules/lib/perl5/5.10.0:/home/shlomi/apps/perl/modules/lib/perl5/5.8. 8
    PERL_BADLANG (unset)

Can anyone reproduce it as well? Just do: rsync -auvz rsync:// perl-5.8.x-latest and then build perl and run "make test"?

I could not reproduce this problem by running "perl Makefile.PL" ; "make" ; "make test" in the latest IPC::SysV. For all the failed tests, the problem seems to be:

shlomi:~/Download/unpack/perl/perl5/maint-perl/perl-5.8.x-1218190282/t$ ./perl -MTestInit ../ext/IPC/SysV/t/msg.t
IPC::SysV object version 1.99_07 does not match bootstrap parameter 1.05 at ../lib/ line 250.
Compilation failed in require at ../ext/IPC/SysV/t/msg.t line 37.
BEGIN failed--compilation aborted at ../ext/IPC/SysV/t/msg.t line 37.
# Looks like your test died before it could output anything.

Tuesday August 05, 2008
04:34 PM

Web Feed Mangling Blues

Back when I was looking for a way to aggregate several RSS feeds, a few years back, I found XML-RSS-Aggregate by Audrey Tang. Using it turned out to be problematic and I had to patch it, sub-class it, and write a lot of code above it to have it behave with my feeds.

Then after I asked Audrey about it on the IRC, she told me that XML-RSS-Aggregate was no longer recommended and that XML-Feed was then the way to go. So I happily switched to using XML-Feed and even packaged it for Mandriva, and all was all. I wrote a 5 star review for it on CPAN ratings, and wrote a 1 star review on XML-RSS-Aggregate directing people to XML-Feed instead.

My problems started again, when after setting up the feed for my XML-Grammar-Fortune-based fortunes, I discovered that the Atom feed did not validate and the RSS feed had many warnings. I ended up maintaining XML-Feed in my own repository, and tried to contact the author of XML-Feed about becoming a co-maintainer.

Now, yesterday, I joined #plagger on Freenode, trying to see how I can make progress there, and miyagawa told me about Data-Feed, which is a new module, which aims to be even better than XML-Feed. I thought to myself "Thanks God!" and decided to try to install it.

Not wanting to pollute my system, I decided to prepare Mandriva RPMs of it and its dependencies, which you can find in the link. I ran into a problem with its tests failing due to the fact what Data-Feed tried doing only worked with XML-RSS-LibXML and not with XML-RSS which was all I had installed. I reported a bug about it, and am hoping for the best.

Today, I decided to try to convert the XML-Grammar-Fortune-Synd code to use Data-Feed instead of XML-Feed and see if it would help me. But then I tried to look up some classes with which I was familiar from XML-RSS and realised that Data-Feed had practically non-existent documentation. So I could not look up that information even if I wanted to.

So I decided to stick with XML-Feed for the time being. Right now XML-Grammar-Fortune-Synd depends on XML-Feed with my downstream patches, and fails all tests, and the Atom feed still does not validate. So it's only mostly broken.

I got the web-feed manglin' Blues!

Saturday July 26, 2008
02:45 AM

The Demise of O'Reilly-Net?

I recall a time, not long ago, when the O'Reilly-Net sites:,,, etc. used to carry weekly or close-to-weekly in-depth articles about various IT-related subjects, that tended to be high-quality and provided a lot of good information. But lately, it seems there were only a few blog posts on about open-source in Windows and other such relatively low-interest or low-quality topics (and practically nothing on or LinuxDevCenter) and no new articles. The latest article on is from 20-May this year (over two months ago) and there were huge gaps between the latest articles there.

Now, I recently sent a suggestion for an article, with an outline, to the editor (chromatic) and to the editor (James Turner), and received no reply. I sent it again, and again received no reply. I sent the second message on 9-July. Now, even if they didn't like the outline, then the right thing to do would be to promptly reply saying that they're not interested in it and that I should seek other venues of publication. I'm pretty sure that at least chromatic is alive and has some spare time, because I've seen him active on and on mailing lists.

I submitted some articles to O'ReillyNet in the past and encountered a few delays in response, which I suppose is expected, but such a long delay is no longer acceptable. My guess is that I'm not the only one who sent such suggestions to O'Reilly-Net and received no response.

If the O'Reilly-Net sites would like to keep their edge, they should make sure they don't turn into another one of the dime-a-dozen blog sites, and instead start offering high-quality articles and essays again. But this will require a better responsiveness on the part of the editors. Would chromatic and/or Mr. Turner care to comment about that?

Wednesday July 23, 2008
01:36 PM

Overcoming Misbehaviours in Code I Did Not Write

Yesterday, when I tried to validate the RSS feed of my fortune cookies, I ran into a Unicode encoding problem. Seems like a Unicode character ("→") was converted into its individual bytes and then encoded using SGML entities. After a long time of debugging it, I found out the problem was with XML-Atom and was easily fixed using:

$XML::Atom::ForceUnicode = 1;

This behaviour is documented in the XML::Atom::Feed documentation, which I didn't bother to read because I believed XML::Feed would do the right thing. The reason I ran into this problem there was because I generated an Atom-based XML::Feed (so I can also have an Atom feed and then converted it to RSS.

Today I encountered, a similar problem, this time with CPANPLUS. I wanted to write a script to syndicate the list of CPAN modules for a the Perl-Israel Israeli Perl Projects page. One thing I noticed was that calling $author->distributions() took a long time. After some debugging, I noticed that the culprit was in CPANPLUS::Module's dslip() method which went over all modules list in O(N) time looking for modules whose prefix is the current module. This was fixed using:

    no warnings;
    # This is an optimisation because dslip is incredibly slow,
    # and it badly affects $module->clone() .
    *CPANPLUS::Module::dslip = sub { return ' ' x 5;};

This made my script run much faster. Not instantaneously, but definitely faster.

So this way, I was able to fix the two problems that I had. Now I'm happy and can go on with the rest of my life.

Tuesday July 15, 2008
08:26 AM

Reflections on Syndicating my Fortune Cookies as Atom

Another technical entry, on my fortune cookies' FortuneXML work again. When I last left you, I was able to transform the XML sources of the fortune cookies to XHTML and to plaintext, and ran into a nasty stack smash that prevented me from uploading the module to the CPAN.

Then, I decided that now that each fortune had its own unique URL, and that people didn't have the time to regularly see what has changed, it was high time to get a web-feed syndication for it. I decided to use XML-Feed directly, and to generate an Atom feed. (So far I only did RSS using XML-RSS).

It seemed logical that I'd simply go over all the individual id="" attributes in the XML files I maintained, and see which ones were added. Then I'll generate a feed containing the most recent 20 or so. However, the XML does not contain the dates where they were added. So I decided that for simplicity I'll record the dates all the IDs were added into a YAML file, which in turn will be updated there. (A database of some sort may be better eventually.)

Now, how to find the most recent 20 dates from the YAML and the XMLs? One option would be to collect all the dates and sort them, but that seemed wasteful to me. Recalling my Computer Science Data Structures studies I remembered that I could use a priority-queue for that, and remembered there was a module for that on the CPAN. A search for "Priority Queue" or "PQ" yieleded nothing, but I then searched for Heap and found, which implements several Heaps that can be used as a priority queue.

Heap is a very impressive module. I remember that back when I studied at the Technion, it used to be the only usable sourceware (and open-source) implementation I found of Fibonacci heaps. I decided to use the Binary heap this time, though.

I had to write some wrapper code to get it working. I decided against writing automated tests before I wrote the code (= "Test-Driven Development") and just write the code and get it to working, because I found that I didn't exactly know what it would generate. Anyway, I now have the script working.

I encountered some problems in trying to find how to render just one fortune element and not the entire file. After not finding anything about it in the XML::LibXSLT documentation, I opted to tweak the XSLT stylesheet and create an optional parameter for it to act upon.

Eventually, I got an Atom feed. Firefox displays it fine, but it doesn't validate. Part of the problem is that I needed to trim down the feed entries' content from the "<html>" and other such tags. But another issue is that XML-Feed does not support all the required Atomisms.

I've noticed both XML-Feed and XML-atom have suffered from neglect (including the lack of support for those Atomisms), and decided to adopt them. I set up a repository for XML-Feed on BerliOS and started to get into it. First thing I did was get rid of ExtUtils::AutoInstall, and I have also given repository access to another person who is interested in revamping them. Thanks to BingOS for helping me with some Module::Install-ism.

As it turns out, the XML-LibXSLT bug was actually a Cooker-specific bug, which seems like it is caused from problematic compilation flags.

So world-domination through Unix-like fortune cookies is still making progress. I'll probably release XML-Grammar-Fortune in its current form soon since the smash stack I got is highly system-dependent.

Thursday July 10, 2008
03:11 PM

Perl and Solitaire Games

This entry will be a technical entry, but on a relatively lighter side: Solitaire games. Solitaire games (also known as "patience" games) are any of several kinds of single-player games played using one or more decks of cards. Despite common belief, the Windows-game called "Solitaire" is actually Klondike, which is only one variant of Solitaire. Freecell is another famous variant of Solitaire.

So anyway, I spent some of the past two weeks working on Games-Solitaire-Verify, which is a CPAN module to verify automated solutions of solitaire games. So far only Freecell is supported, but there's a lot of modularity in place for other variants. The intention of this module is to be used as part of the automated test suite of Freecell Solver, which is a solver for several variants of Solitaire, which lacks a comprehensive test suite.

I should note that I implemented the very first version of Freecell Solver in Perl, but it was horribly slow. Of course, I did some very illogical things speed-wise, like (1) putting all the states into an unsorted array and using linear search to scan it - and (2) constantly deserialising states into objects and data strcutures of individual cards, columns, and boards, and doing the comparison the hard way. So it was dog slow. I ended up re-implementing it as (saner) C code which turned out to be considerably faster than the Perl version. Moreover, my next C version was faster by a factor of about 100 (not because I was smarter, but I was less dumb), and since then I incorporated many other speed optimisations. (There are also several C and Assembly-hosted solvers that are much faster than mine.)

In any case, someone contacted me about the solver on Facebook, and after talking to him on Yahoo Messenger, we decided that he, I and another guy will talk on Freenode on the newly started #solitaire. There, I was quickly quickly joined by tybalt89, who is a master golfer, and who decided to write his own solver for Klondike in Perl. After a while he finished it and so I took a look at the source code.

From my impression it seems like the kind of code a golfer would write: strings instead of objects (with regular expressions and other text processing to manipulate them), a call to shuffle() from List::Util with a random seed, no use warnings, lots of obscure two-letter variable names, a lot of trailing "or" clauses, and it also has $hearts, $clubs, etc. instead of a hash. I talked about it with another master golfer and he said that "golfing rots the brain", and he said a program he gave as a solution to someone's problem had many golfish paradigms as well.

tybalt89 reported that his program is relatively fast, but still fails on many deals.

Meanwhile, I finished writing Games-Solitaire-Verify and released it on the CPAN. Then I decided to test if it could detect than invalid solution was indeed invalid. And it turned out an invalid solution was still reported as valid (!) making the reported verdict useless. What I found out was that the complete solution analysis silently stopped after the first move or two.

I fixed the bug and released a better version (with more tests). Then I decided to extract a few more classes (Games::Solitaire::Verify::Freecells and Games::Solitaire::Verify::Foundations) out of the relatively monolithic ::State class (which represents positions of the board, including those at midplay), and uploaded version 0.02.

I still need to adapt the module to verify solutions of other variants except Freecell, and that's what I'm planning to work on next. But it was good enough to add some system tests to Freecell Solver (using Perl, Test::More and TAP). What I hope is that tests such as this will allow me to revamp , refactor and enhance Freecell Solver with more confidence that I didn't break anything. I'm especially looking forward to the conversion from GNU Autoconf to CMake, which depends on the test suite to make sure it doesn't break anything.

Finally, I also found out that my C-based Freecell Solver program, did not always output things the right way, without trailing whitespace, etc. Since my primary motivation with Games-Solitaire-Verify was to verify the solutions of Freecell Solver, and because I wanted to compare to the precise output, I needed to emulate these mis-behaviours in my Perl code as well. I don't like it very much, but I guess I'd rather emulate Freecell Solver to test it, than fix it and risk breaking something. Nevertheless, my intention is to provide flags for a saner output for both the C and Perl programs in the future.

Happy Solitaire!

Wednesday July 02, 2008
04:31 PM

Freenode Channel for Catalyst - ##catalyst

Since I'd like to start working on a new Catalyst-based project, and since I cannot and would rather not chat on, and since #catalyst (with a single sharp-sign) on Freenode exists only to redirect people to, and they don't tolerate any other discussion there (which is probably against Freenode policy, but that's life), then I've started a new channel.

Introducing ##catalyst on Freenode - the unofficial and completely non-hostile Catalyst channel. We're already 5 people and one super-intelligent bot there. If you're interested in Catalyst, then please consider joining it too.

You and I Will change the world.

Sunday June 29, 2008
03:05 PM

Dealing with Approval Addiction (and Implied Stress Periods)

Well, despite the fact that I hardly publicised my last essay about the "Closed Books", it has been chromatic'd. Rumours are that all the bloggers whose blog posts/essays were deprecated on chromatic's blog are now rich, famous and the object of the affection of many attractive members of the appropriate sex. Memo to self: prepare a limited edition T-shirt: "My blog post was chromatic'd. I pwn you as a blogger."

Seriously now, while the publicity was probably good for me, I was indeed a bit overwhelmed with what chromatic said, and felt down. It's not because I believed I was wrong, but because I respected chromatic, because he's a good programmer, a good author, a good editor (with whom I collaborated on several articles on O'Reilly-Net), an interesting blogger, and a good guy. (And yes - these are all compliments). I'm not sure he's really a friend of mine, but I certainly respect him.

Now Paul Graham says in "What you'll wish you'd known" (footnote 4) that:

The second biggest regret was caring so much about unimportant things. And especially about what other people thought of them.

I think what they really mean, in the latter case, is caring what random people thought of them. Adults care just as much what other people think, but they get to be more selective about the other people.

I have about thirty friends whose opinions I care about, and the opinion of the rest of the world barely affects me. The problem in high school is that your peers are chosen for you by accidents of age and geography, rather than by you based on respect for their judgement.

Now in my case, I may be somewhat immature because I tend to sometimes care about what many people think of me, rather than just my close friends (offline or online). Now being down (or "depressed") because someone disapproves of you, is perfectly natural and normal. However, since I have Bipolar disorder, it threw me into the so-called "hypomania" (= "below-mania"), which is not healthy, and disrupts my functionality.

Hypomanias are a variation of "Clinical Depressions" or "Clinical anxieties". Dealing with the latter is described in the highly recommended book "Feeling Good", which I believe is a necessary read even for non-depressive people, in order to understand how people think, and as a preventitive measure.

I don't accuse chromatic of making me hypomanic. I've received my share of past criticism in the past, and will receive again. I also was often criticised for insulting people myself, due to the fact I tend to be tactless. How you deal with criticism is ultimately the responsibility of the receiving end, as even for me, most criticism will not affect me.

In any case, Feeling Good mentions four general "addictions" that can make one clinically depressed (or Hypomanic):

  1. Approval Addiction.
  2. Productivity Addiction - you care about your work, how productive you are, how much you achieve, etc. (Much more common among men.)
  3. Love addiction - you want to be loved a lot. More common among women.
  4. Perfectionism - you want to be perfect in everything you do.

Now based on reading the descriptions in the book, I believe I have been having Approval Addiction and Productivity Addiction, and neither of the other two.

I used to get into clinicial depressions and anxieties (due to approval, etc.) which are even worse to deal with than hypomanias are. And during Manias, which I also had, but must avoid at all costs from now on, I lose most control of myself.

I started writing an essay titled "Dealing with Hypomanias". It is not professional Psychological advice, as I am not a qualified therapist, but it is given as a way to dispense my advice from the Point-of-View of a Bipolar person, who's learned a little about it. It's still very rough on the edges, as it started from a plain-text email, but any constructive comments would be welcome.

While I may be a bit immature due to my approval addiction, I'm still mature enough to learn from my mistakes. At one time, a prominent member of the Linux-IL mailing list said there that one should not take the advice I've given in the "End of Info-Tech Slavery" (an essay I still mostly stand by, but am about to update with a sequel/correction), and rather take the advice in my links. I was offended from it. Then I understood he was over-generalising and not criticising any of the points I raised in my essay, or explaining why he disliked them, and realised that he was very intelligent, but nevertheless what people call an "idiot". So when he said he doesn't think my Random Tweakers idea for a startup have commercial value (again without properly explaining why or without asking me how I intend to make money), I didn't take what he said to heart.

So now I think chromatic will "suffer" a similar fate in his criticisms against me. No, chromatic is certainly not an idiot, at least not in most regards. But now I know better than to take what he says to heart. I'll listen to what he says and read it at my free time, and often find merit in what he says, but he's still someone I know better than to be affected by him.

I'm not disabling comments here, because I have a policy against it, due to the fact that I believe a blog post without comments is anti-social and defeats the point. But please be gentle, civil, rational and logical. I'm still a bit hypomanic now, though it's getting better, and don't need any more grief. (However, I don't guarantee I'll read what you said immediately, or reply to it.)

I feel this was probably the most off-topic journal post I ever posted, but I've seen much more off-topic blog posts on, and it is relevant to open-source software, as I'm certainly not the only FOSS geek who is either Bipolar or much less Unipolar/Depressive.

And in case you wanted to suggest that: yes, I am taking medication - it doesn't absolutely prevent the hypomanias, but it may help (not sure about that). And I am seeing a Therapist, who gave me a lot of good advice. I should do the so-called "Cognitive Exercises" more-often, but I'm usually carried away with chatting or working on code or text to do them, but they do help a lot.

Here's hoping we can deal with our frustrations more easily, because people are not perfect and the world is not perfect, but they are still pretty darned good.

Thursday June 19, 2008
03:51 PM

New Essay about Open-sourcing Books

A conversation on Ask Bjørn Hansen's blog (famous for being an administrator of and involved in other Perl-related projects) prompted me to write this essay, which talks about why it is unwise and harmful not to make one's books publically available online. Perl is mentioned there and so is Ruby and git and other technologies.

Comment here or on the announcement of the essay on my homepage's blog, where no registration is required for commenting.

Thursday June 12, 2008
04:29 AM


One of my many computerised passions is to collect quotes in UNIX-like fortune format. Throughout the years, I have formed a moderately large collection of them in several files. As time went on, I noticed a few problems. First of all, they were all in large plaintext files, and pointing someone to a quote involved giving a link to the fortune, and saying "search for Foobar". Moreover, since they were just chunks of text, they couldn't hold any meta-data.

At one time, I heard of someone who created an XML grammar to describe Unix fortunes, but a Google search was no help in finding that. And I also have the grand "Fortunes Mania" vision for a community site that for collecting and sorting quotes. This vision was very intimidating, but recently, I decided to take a small baby step by defining a grammar for fortunes as XMLs. So I present to you the XML-Grammar-Fortune distribution.

I've taken quite a lot of time to think about what I wanted there. One thing I concluded was that there are several different types of fortune cookies: run-of-the-mill quotes, IRC conversations, excerpts from screenplays, structured plaintext, HTML, etc. Therefore, the XML grammar should be able to have several different types of sub-nodes, which each corresponds to a certain class of fortune cookies

Until now I've used DTDs for defining my XML schemas, but for XML-Grammar-Fortune, I decided to learn Relax NG, which I was told was easier than the W3C XML Schemas. I was very impressed from Relax NG - it's easy, it's fun, and it's powerful. One problem I've encountered was that, when validating a document using it, XML::LibXML (version perl-XML-LibXML-1.66-1mdv2008.1), does not give the line number where the validation error has occured. To overcome such problems, one needs to look at the diffs or bisect the document.

Anyway, I defined a Relax NG Schema for the documents, and made sure that some basic examples will validate (test-driven-development-style). Then I worked on an XSLT stylesheet to convert them to XHTML.

When I started, I only had one fortune type - <raw>, which is a gigantic <pre> block with some meta-data. I gradually implemented more fortune types: irc, quote and screenplay, whose RNG and XSLT were based on XML-Grammar-Screenplay, with a lot of ugly copying-and-pasting.

I gradually converted more and more fortunes to have a richer XML semantics. The XML grammar requires an id for each fortune, and also allows specifying a title-element, and some fields in the <info> tag, like "author" or "work". For example all the "Friends" fortunes were converted to XML by first normalising the screenplay and then using a script I wrote to convert them to XML.

So I had all the fortunes as XMLs, but now the plaintext versions went out of sync. So I coded a Perl module to convert them from XML to plaintext.

I should note that due to a problem with XML-LibXSLT and perl-5.10.0, I didn't upload it to CPAN yet, because I do not want to receive so many failure reports.

On a different note: my former co-worker has read "Perl for Perl Newbies" in order to learn Perl, liked it a lot, and told me I should add more to it. That also feels good.