Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

how to migrate a large perl 4ish CGI site to mod_perl

by qq (Hermit)
on Jun 19, 2004 at 13:53 UTC ( [id://368172]=perlquestion: print w/replies, xml ) Need Help??

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

I'm working on a large, dynamic web site thats written in a perl 4ish style. No strict, warnings, modules, OO, templating or even CGI.pm. Lots of global variables, subs called with &do_something; syntax (accessing enclosing @_), database access on every page with hardcoded dbi strings. In short, the very opposite of what the monks consider good style. It does, however, work (albeit with a few dropped database connections and a bit slow.)

The current environment is perl 5.8.3, apache 2. The wish is to migrate to mod_perl and clean it up.

The minimal option is to clean each page that breaking under mod_prel or when new functionality is needed. Add strict, warnings, obvious modules (CGI.pm?), but still keeping it as CGI-ish, and letting the Registry modules handle the mod perl integration.

The maximul option is to redesign the site from scratch, using mason or Template Toolkit. Then flip the switch. This seems like overkill unless serious new functionality is being considered.

The question is - how much to do, and how to do it.

A hybrid approach seems possible, but perhaps more difficult to plan. Can you slowly transform a legacy site into something that looks freshly built? Any advice on strategies, tips, pitfalls, resources (is Practical mod_perl worth the read?), etc., much appreciated.

There are interersting CGI/mod_perl discussions at these nodes 174307, 253921, 367315, and the official porting guidelines.

thanks, qq

Replies are listed 'Best First'.
Re: how to migrate a large perl 4ish CGI site to mod_perl
by CountZero (Bishop) on Jun 19, 2004 at 14:13 UTC
    One (obvious) option is to first switch to plain but modern (Perl 5.8; CGI.pm; use strict; ...) CGI-processing. If that works, introduce the Registry-modules and if it still works go the full mod_perl way.

    Practical mod_perl surely is a good read, but does not deal much with migrating from Perl 4 to Perl 5.8. For that you need Perl Medic. Full of practical tips and tricks.

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

      Perl Medic is an excellent book, and I'll certainly be consulting it. I'd recommend it for any perl programmer, not just if you have legacy code to support

      Let me second the recommendation for Perl Medic. In particular, chapter 11 is very similar to what you describe.

Re: how to migrate a large perl 4ish CGI site to mod_perl
by BUU (Prior) on Jun 19, 2004 at 22:57 UTC
    Personally this sound ripe for using Test Driven Development. At the very least I would write a basic test suite, preferably broken down by component. Once you have this test suite in place you can trivially make any changes and *know* they work. This is invaluable. Once you have a test suite in case you can easily redesign the application from scratch because you know *Exactly* what functionality it has to have.
      Perl Medic makes it very clear that a test suite is a basic requirement to modernize legacy code. other wise you never know that the chances you make will not break the application.

      That and a good versioning system (CVS, Perforce, Subversion, ...) is the way to go.

      CountZero

      "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://368172]
Approved by adrianh
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (6)
As of 2024-03-28 09:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found