in reply to Migrating from PHP to Perl for the web.

As PHP is directly included in your webpages, it is more akin to working with a templating framework in Perl. Examples are HTML::Embperl, Template Toolkit or HTML::Template and such.

An MVC framework such as Catalyst makes extensive use of this. Perl does all the heavy (computational and database) lifting, the template allows you to write your webpages quite easily and an OO-wrapper around your database makes for an easy and consistent access to your data.

At first --and to many a PHP programmer-- this seems unnecessarily complex, but actually it makes for far cleaner code. Changing the data-store is done only in the model-layer (which is mostly just some config-files), the business logic is found in the Perl code in the controllers and the eye-candy for your web-page is found in the view layer of the templates. You will be hard-pressed to maintain such a nice separation of concerns in your PHP-application.

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

  • Comment on Re: Migrating from PHP to Perl for the web.

Replies are listed 'Best First'.
Re^2: Migrating from PHP to Perl for the web.
by monarch (Priest) on Dec 01, 2007 at 11:41 UTC
    Another technology that you might seriously consider is the use of Mason. This is an open-source handler for Apache that interprets web pages much the same as PHP, and looks for embedded code.

    Mason can be quick if it uses mod_perl as pages are cached as compiled objects in memory. Mason offers a debugging mode that displays compile errors to the web.

    There are programming purists who don't like Mason, but I've used it professionally and found it a good compromise between developing CGI applications quickly and good web performance.

    Have a look at the brief Mason Introduction - it offers the following example of a Mason-interpreted file:

    % my $noun = 'World'; Hello <% $noun %>! How are ya?