Anyway, this is general database problem and hopefully it can be done using DBI modul for Perl.
For example, database is a catalog of all of departments of some company (no matter which one). Each department can contain divisions, each division can contain something, and it goes like this for unknown number of times. The depth level is unknown. The script must be general in a way that it displays whole content no matter how deep it goes.
Thanks.