in reply to (OT?) Recursive sql queries?

You will have to create a lot LESS perl code, if you use Class::DBI to define your tree structure. You could do something like this:
package TreeNode; use base 'Class::DBI'; __PACKAGE__->table('forrest'); __PACKAGE__->has_a(parent=>TreeNode); __PACKAGE__->has_many(children=>TreeNode);
Note that there are several ways of representing a tree structure inside a relational database:

Each of those representations has it's advantages and it's disadvantages, depending on what you intend to do with the tree once you have it in the database.

Whichever method you choose to implement, I am willing to bet the code will be much cleaner (more readable and easier to debug) if you use Class::DBI than if you use straight SQL in the code.