Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8883641
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:51:51+00:00 2026-06-14T20:51:51+00:00

I have a relatively large legacy Perl/CGI/DBI web application which generates HTML on-the-fly piece

  • 0

I have a relatively large legacy Perl/CGI/DBI web application which generates HTML on-the-fly piece by piece. We are reworking the HTML being produced, to come in to compliance with HTML 5 / CSS 3. This would be a good time to move to some sort of template system. We do NOT want to engage in a complete rewrite, and thus do NOT want to migrate to a framework such as Catalyst.

I’m thinking that Perl Template Toolkit might be our lowest-impact means. I’m re-reading the venerable Badger Book to study up on feasibility.

My question is this. Has anyone here migrated “old school” Perl web code to Template Toolkit? Are there any tricks you can share for minimizing the rewrite/rework needed? We have not 100% decided on Template Toolkit, either. If there is an alternative which we should consider?

What problem, specifically, are we trying to solve? We’re generating invalid HTML and need to clean that up. Since we’re cleaning, we want to produce fully-valid HTML 5 and, to the extent practicable, valid CSS3 and Javascript. We use jQuery, jQuery UI widgets, and AJAX via jQuery. We have typical Page Controller MVC architecture except no View layer as such. We’d like to go to some sort of template system but don’t want to rewrite everything (or much of anything!) to migrate.

Thank You!
Ed Barnard, Cannon Falls MN

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:51:53+00:00Added an answer on June 14, 2026 at 8:51 pm

    Here’s what I’ve found, as I’ve moved my practice from CGI.pm to TT, and what I’ve also learned along the way using HTML::Mason, HTML::Template, Text::Template, and working with ERB and HAML in Rails.

    1. The more logic you have in in your displays, especially if it is written in a display specific language, the less fun you’re going to have.
    2. I’ve come to prefer HAML for the reduction in size of the contents of my templates [ In HAML, closing tags are implied by indentation ]
    3. Perform as much of the logic to compute the various dynamic bits of the page before you drop into the template, in the application’s native language. [ call view methods, before engaging in rendering ].
    4. In relation to (3), by using methods, instead of inline display/rendering logic, you can make your templates declarative, so while you might be performing logic in the middle of the render, your templates don’t have a bunch of IF/THEN/ELSE logic causing clutter.

    Let’s imagine a reasonably small, contrived web page made up of a header, and footer and a body. Let’s assume that the footer is completely static, the body changes every time a new page loads, but the header only changes when a user logs in/out.

    You can imagine the header containing code like this:

    <header>
    [% IF $user.is_logged_in THEN %]
       Hello [% $user.name %] - <a href="/logout/user/[% $user.id %]">Log Out</a>
    [% ELSE %]
       Please <a href="/user/login">Log In</a>
    [% END %]
    </header>
    

    But you’re better off in the long term doing this in header.tt:

    <header>
      [% user_info($user) |html %]
    </header>
    

    and this in View::Helpers::Header.pm:

    sub user_info {
       my $user = shift;
       if ($user->{is_logged_in} ) {
         return "Hello $user->{name} - " . logout_link($user->{id});
       }
       else {
         return "Please " . login_link();
       }
    }
    
    sub logout_link {
      my $userid = shift;
      return qq(<a href="/logout/user/[% $userid %]">Log Out</a>)
    }
    

    You can, of course, implement the view helpers in TT rather than pure Perl, and I don’t have any kind of numbers for you, but if you’ve done all of your logic in Perl already, you can refactor the Perl into modules (if it isn’t there already), instead of re-coding them in TT.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a relatively large web application (>200 pages) to which we need to
I have this relatively large numerical application code that may run for a few
I have some relatively large legacy method that I would like to refactor. It
My relatively large program has a PDF help file which I have put together.
I have an image which has a relatively large area of transparency, alpha space.
I have a relatively large database application that has a user table with a
I have a relatively large database (130.000+ rows) of weather data, which is accumulating
I have a relatively large (as in >10^6 entries) table called things which represent
I have a relatively large PHP-codebase (thousands of lines) for an application built with
I currently have a relatively large HTML form (100+ fields). I want to take

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.