SPUG: Re: Perl and HTML
burkenholt at home.com
Tue Oct 24 13:38:11 CDT 2000
At least for me, it all depends on if you want to see what you're doing as
HTML with code in it, or code with HTML in it.
Using a hybrid system, where code is embedded IN the HTML (as opposed to
HTML embedded in the language) is far easier to manage for some projects.
PHP's been great for this by me. Anyone have any experiences with embedded
----- Original Message -----
From: <Showell30 at aol.com>
To: <spug-list at pm.org>
Sent: Tuesday, October 24, 2000 8:59 AM
Subject: SPUG: Perl and HTML
> Since Jason has opened up the topic of Perl and HTML, I will throw my two
> cents in.
> I am working on a project where I have a bunch of web pages with
> family/vacation photos that I need to tie together, giving them common
> look-and-feel, common table of contents, etc.
> I considered a template approach, and decided against it for a a couple
> 1) If your template solution does not have an "include" feature, it can be
> difficult to reuse HTML.
> 2) If you do use the "include" feature, you can quickly have a bunch of
> hanging around, which gets to be a mess after a while.
> 3) I've done template solutions before that were ugly (non-Perl, though).
> 4) I think of data first, presentation second, so templates just seemed
> for my coding psychology.
> 5) This is a personal project, so I can afford to be lazy and wrong about
> Anyway, I decided to use HTML::Subs and HTML::Entities instead. I have
> those to be very smooth sailing. Here is what I like:
> 1) Code is prettier -- no matching of start and end tags (although some
> argue matching parens is just as bad).
> 2) Reuse scheme is more Perlish to me. If I have a cool way of laying out
> table, I share it by making a subroutine to return the table widget,
> a template solution might lend itself to having an include file.
> 3) My approach does not preclude templates in the future. I do 90% of my
> HTML through Perl subroutines, but sometimes it's easier just to code up a
> little raw HTML, and I either do that as a here document, or I slurp it in
> from a file, and then I use HTML::TreeBuilder to stick it into my
> HTML::Entities tree.
> Having said all this, I must say that a friend of mine has done a very
> similar project w/posting photos to the web, and he went the template
> approach. He went with (gasp) ASP, and I must say, his code looks pretty
> clean and maintainable. Also, at the last SPUG meeting, the slashcode guy
> says that they have been happy with the template solution. Even so, I am
> content with my non-templates solution.
> If you do go the Subs/Entities route, here are some headaches that you
> 1) Tr for table rows can trip you up, if you don't realize it's a reserved
> word in Perl. This is well documented, but I got tripped up on it any
> 2) It seems hard to get  's into the page, without them being
> overtranslated. The workaround is easy, though.
> 3) Mixing raw HTML into the Subs/Entities data structure was tough for me
> first. In the end, I wrote like a three line function that used
> to solve the problem, but I wish this had been documented better, or if
> is an even simpler way, I wish it were documented more clearly.
> One last thought for Jason -- check out the Data::Locations module. Even
> you don't use it for HTML, it's great food for thought.
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
> Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
> Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
> For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
> Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
POST TO: spug-list at pm.org PROBLEMS: owner-spug-list at pm.org
Subscriptions; Email to majordomo at pm.org: ACTION LIST EMAIL
Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
For daily traffic, use spug-list for LIST ; for weekly, spug-list-digest
Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/
More information about the spug-list