Hi,
I think I talked to you on the Class::DBI mailing list. I just wrote up a big long response and then lost it when I accidentally closed the browser. I don't have the patience to type it all in again, but here are the major points:
- Read some articles about using the model-view-controller pattern with Perl. You can find some on here, and there are some on perl.com, including one that I wrote.
-
Imagine that your code has to produce a data structure with zero HTML in it so that it can be used on a dozen different sites with different layouts, including one that uses PDF and one that is plain text e-mail.
-
In yur example, I think you'll have a list of countries each of which contains a list of regions, each of which contains a list of wines. Each country, region, and wine will end up being a hash. Those hashes could potentially be represented as objects, and you could make Class::DBI classes for them, although in your example you have used a single large query instead of traversing object relationships to get the data.
-
Figure out how to make your code produce that data structure instead of producing HTML.
-
Write a template that takes that data structure and produces the HTML you want.
-
You want the template to be as simple and as dumb as possible.
To answer your question about CSS, it's mostly irrelevant. The templates can contain any HTML you want including CSS. The important thing is that they only get to look at the data, not change any of it.
I hope that gets you started. If you come to a New York Perl Mongers meeting I can show you how to do it in detail.