The 2001 Perl Advent Calendar
[about] | [archives] | [contact] | [home]

On the 11th day of Advent my True Language brought to me..

Talking about POE as a module is weird - to me it's a whole other way of thinking.

POE is essentially an event queue system where you can set up handlers that deal with things by defining "states" that the routine should enter if certain things happen. Basically the idea is that you do very very little in each state and try to get back to the main loop as soon as possible. This is essentially co-operative multi-threading - each time something happens you deal with it a little and hand back control to the main loop that then decides what to do next.

This is all very different from a normal perl program. No longer do you control where the flow of control goes...if you want to call something else you really should express a desire to the POE kernel that in the not too distant future that state be entered. This is obviously more complicated but comes with the advantage that POE is able to interleave your tasks with other pressing tasks (for example, competing 'threads' or updating the display) and you don't have to worry about it.

Of course, there are other event loop type systems out there that you can use. Both Tk and Gtk have event loops of their own and use their own handler system that similarly is triggered whenever a UI event occurs. What I really like about POE is that it plays nicely with these systems and cooperates with them, meaning that you can use the Gtk or Tk loops just like they were POE loops and everything works just as you would expect it to.

POE is not a simple module, and it does come with a whole large collection of mnemonics, cultural shifts, odd paradigms and conventions that you must get your head around before you can get to grips with it - but when you do you'll never look back.

  • The POE homepage