leighsharpe has asked for the wisdom of the Perl Monks concerning the following question:

Esteemed Monks,
I have been tasked with modifying a CGI app which runs on a hosted server running perl 5.004 on Solaris.
I have no control over the server, nor what modules are installed on it.
The existing app uses a lot of HERE DOCs to print HTML, which does not fit very well with the client's requirements. I want to convert it all to use templates, such as HTML::Template or Template::Toolkit.
Can anybody suggest a pure-perl templating system (so I don't need to install modules, I can just upload a .pm) which is known to run on such an old version of perl?

Replies are listed 'Best First'.
Re: Templating system for older perl
by almut (Canon) on Dec 20, 2008 at 10:52 UTC

    AFAIK, Template Toolkit can be operated as pure-Perl (use the regular Template::Stash implementation instead of the Template::Stash::XS version). I'm not sure if it's 5.004 compatible, though...  but it shouldn't be too hard to find out by just trying (i.e. running its test suite).  (Update: just checked my older projects and found one using TT from the year 2000. I'm pretty sure it was deployed to a system running Perl at least as old as 5.005 (might even have been 5.004). IOW, your chances are not too bad...)

    OTOH, it's not the fastest module if you're running plain CGI (as opposed to a persistent environment such as FastCGI or mod_perl) — quite a lot of code/files to be compiled on every request.

Re: Templating system for older perl
by moritz (Cardinal) on Dec 20, 2008 at 11:06 UTC
    I've search CPAN for distributions with Template in the name, and clicked on the "Perl/Platform Version Matrix" link for a dozen distribution, and the oldest test reports where from perl-5.005 (heck, I silently curse Slaven each time he sends me FAIL report with his ancient 5.005).

    So your best bet for getting libraries for an eleven year old perl would be to look on backpan for older modules. For example here you can find old versions of HTML::Template, and try which one work on your system.

Re: Templating system for older perl
by tirwhan (Abbot) on Dec 20, 2008 at 11:29 UTC
    I have been tasked with modifying a CGI app which runs on a hosted server running perl 5.004 on Solaris.

    Tell your company to upgrade. If they won't, get another job.

    Sorry, but any company that wants to run their publicly open services (I take it this is the case from "hosted server") on a platform that was released in 1997 and has not been maintained since then is just too crazy to want to work for. If you were a truck driver, would you consent to driving around in a rig that hasn't seen the inside of a mechanics shop this side of the millennium divide? This is software, so your employers won't be dragged to court by the health and safety people for such a stunt, but they still need a reality check.


    All dogma is stupid.