note
dragonchild
You have hit upon something most experienced developers call "Separation of Concerns". It's the underlying principle behind MVC - Model / View / Controller. (It's called by other names, but that's the most popular.) It was also a driving force behind creation of OO methodologies.
<p>This is usually seen in Perl with the use of templating systems, like [cpan://HTML::Template] or [cpan://Template|Template Toolkit], for separation of Perl (business logic and engine, or Model / Controller) from output generation (View). Other distributions, such as [cpan://SQL::Catalog], can help with the separation of SQL (data logic, or Model) from Perl (business logic and engine, or Model / Controller).
<p>Many people, including myself, tend to provide for a different separation between HTML, CSS, and Javascript. I look at the View layer as generally composed of three elements:
<ul>
<li>Layout (HTML)
<li>Style (CSS)
<li>Client-side interaction (JS)
</ul>
<p>Perl tends to not be involved with those at all, except for ease of maintenance in the assembly of the pieces. So, I tend to have different directories for each (/templates, /javascript, and /css). So, if I were truly separating out the five languages, I would have the following directories:
<ul>
<li>/lib (Perl modules)
<li>/sql (SQL catalog) (I tend to not use this one, preferring to embed my SQL within a separate Perl module designed specifically for database interaction.)
<li>/templates (H::T or TT templates that bring together the various View components, plus contain HTML)
<li>/javascript (Client-side interaction)
<li>/css (Style sheets)
</ul>
<p>Most examples you tend to see are for complete newbies, who just want something to get them up and running quickly. The reason for that is that newbies <i>need</i> to have instant gratication, or they give up. Later, if they are interested, they will do what you're doing - come to those with experience and ask for advice. At that point, you'll improve your code. :-)
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-85580">
<p>------
<br><i>We are the carpenters and bricklayers of the Information Age.</i>
<p><i>Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon.</i> - [flyingmoose]
<p>I shouldn't have to say this, but any code, unless otherwise stated, <i>is <b>untested</b></i>
</div></div>
390216
390216