Comparing PHP to a Perl CGI install is a bit flawed. To more accurately show the difference, you'd have to be comparing it to something like mod_perl + Mason.
Mason example:
m
<% print "Hi!" %>
vs PHP's:
<? print "Hi!" ?>
Mason lets you embed in an identical style to PHP, the barrier to entry is due to installed code base with most shared webservers. You want popular forum software? VBB and PHPBB are both PHP. You want a Bloggity blog blog blog? Wordpress,
Moveable Type (Edit: MT is perl, woo :) ) and pretty much every other blog outside of Blosxom are PHP. You want a CMS? All those nuke etc sites that aren't based off of the PHP forums are PHP, with the exception of Drupal and Everything engine(Actually Drupal may be PHP now, I forget - point still stands).
I barely touch PHP, but run mod_php on my server due to all the other software that needs it(hosting friends sites and such). Unfortunately that precludes me from running mod_perl on the same server unless I have a high demand app that needs it. Running both simultaneously is only suggested if you enjoy using up all your ram. This also leads to me finding PHP equivilents to the applications I may prefer to have in perl, and jsut contributes to the problem. That, and laziness on my part for not coding more of it :p
One day, I'll probably mess around with Mason again, as the last I checked they didn't have native mod_perl2 support, so I didn't get farther then playing with it. It's really amazing how it addresses everything PHP can do, while adding in new paradigms like init and argument blocks, alongside being able to include other files with said arguments.
Random Examples of Mason awesomeness:
Simple site with dynamic includes:
<& ../check_auth &>
<& ../header, title => "Welcome ".ucfirst(lc($user)) &>
<& tabrow, active => 'main' &>
<& ../iconcol, active => 'user' &>
<div class="content">
Woo! Lookit me! I have content! (User/Main)
</div>
<& ../footer &>
The header included in above site:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=IS
+O-8859-1">
<TITLE><% $basetitle %></TITLE>
<& css &>
</HEAD>
<BODY>
<%args>
$css => "main.css"
$cssinclude => 0
$title => ""
</%args>
<%init>
my $basetitle = "MasonTest";
$basetitle .= ": $title" if $title ne "";
</%init>
Damnit, now I have to go play with this stuff again. :/
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.