From: <sono...@fannullone.us> I realize that this list may not be the best, or even most appropriate, place to ask this question, but I'm just so curious that I'm losing sleep over it! =;)
What is the best way to embed perl in an HTML file that is _not_ located under the cgi-bin directory? I started learning PHP for this very reason, but I keep coming back to Perl. I've read some about Template Toolkit and others, but what I'm still confused over is if these templates _must_ be located in cgi-bin or can you embed code anywhere on your site? If possible, I would like to be able to embed perl, placeholders, templates, whatever, anywhere on my site. Perhaps I'm working under the wrong impression, but for some reason I'm thinking you can't. Hopefully I'm wrong. Any help in pointing me in the right direction will be greatly appreciated. Do you want to create say... a file like "index.pl" that contains something like: <?perl use DateTime; print DateTime->now->ymd; ?> Some HTML code here <?perl some Perl code here ?> If the answer is yes, then no, it is not possible to do this in Perl, and it is not recommended to do it in PHP either (although this seems to appear as beeing the biggest advantage of PHP for the beginners that past from HTML to server side programming.) It is not recommended to do this because it is not recommended to mix HTML code and programming code. The recommended way is to use a templating engine like Smarty under PHP, or Template-Toolkit under Perl. There are more templating engines for Perl, like Mason, HTML::Template and many others but the most clear and used seems to be Template-Toolkit. As well as for a web designer is recommended to keep the JS code, CSS code and HTML code in separate files if possible, for a server-side programmer is recommended to keep the programming code separately. In a Mason template you can embed Perl code directly, but it becomes harder to maintain on the long term and it might make the life of the web designer harder. You can also embed Perl code in a Template-Toolkit template, but it is not recommended to do that for the same reason, however Template-Toolkit has its own limited language which is simple and clear. If you'll use a web framework like Catalyst, you don't even need to define the object variable that need to render the templates, because this is done automaticly, as many other things, so you don't need to be afraid to start learning to use a templating engine like Template-Toolkit. Octavian -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/