Yannick Warnier <[EMAIL PROTECTED]> wrote:
: 
: But PHP, I think, integrates html code a better way. You can
: just type your html code and then say <?php code ?> and there
: you put the varying code. This is a good solution when you
: want to separate content and presentation. I don't know but 
: you'll tell me... does that exist in perl.

    The Good Things about separate content and presentation on
a web site also apply to programming. Embedded programs require
either a special editor or the tedious searching of every file
to update and maintain code. New programmers who start with PHP
learn from the beginning this Bad Thing. Down the line, many
realize the mistake of not separating programming from content
just as many web site designers are jumping on CSS to separate
content from design.


: As far as I know, you still have to do a perl script and
: then put 
:   print <<"EOF";
:     code
:   EOF
: to get some html easily. Isn't that ugly? (beeeeeeh! :-D).

    Let me introduce you to HTML::Template. Here's part of a
bare bones content management system I just wrote for an ASP
system. Notice the complete lack of xhtml.

my $query = CGI->new();
if ( $query->param() ) {

    # Update content-right.asp
    update( '/content-right.asp', '/cgi-bin/content-right.tmpl' );

    # Update the original form
    update( '/site/admin/frontpage.html', '/cgi-bin/frontpage.tmpl' );

    # Update the member article
    update( '/site/code/MemberArticle.asp', '/cgi-bin/MemberArticle.tmpl' );

    # Update the content-left
    update( '/content-left.asp', '/cgi-bin/content-left.tmpl' );
}

print $query->redirect( "/site/admin/" );

sub update {
    my $query = CGI->new();
    my $root = 'D:/hshome/dfwrein/dfwrein.com';
    my $template = HTML::Template->new(
                        filename            => "$root$_[1]",
                        associate           => $query,
                        die_on_bad_params   => 0,
                );

    my $file = $_[0];
    open my $fh, ">$root/$file"  or die "Cannot open '$file': $!";
        print $fh $template->output;
    close $fh;
    return 1;
}

    No html in the script at all. Got a complicated application?
Check out CGI::Application. Got a designer or a webmaster who
can't stand the utilitarian approach you used in form design?
Let them edit the templates which contain no perl whatsoever.

    When I embed ASP in html, I try to isolate the programming
from content as much as possible. I'll create either a "constants"
script that is included with the Global.asa file or specific
functions that need inclusion (SSI) to run. That way content
writers get functions like: <% = TopUsersByPosts( 20 ) %>,
instead of long strings of code that content writers probably
don't need to see or to understand.

    PHP tends to teach new programmers to embed their scripts
directly into their web pages. This makes maintenance difficult
and supports an idiom that will become even more of a problem
as xhtml starts being replaced by its successor (whatever that
might be). Changing a site that uses embedded PHP in html to
PHP embedded in xhtml would be tedious at best.


: To find any answer about some common matter in Perl, you have
: to crawl the web. Or ask here (which is the simplest way I
: have found, but sometimes nobody can answer and then...).

    Or use perlmonks.com. I use a search for answers to most
of my server side vbscript questions. I find it very effective.


: -- But there surely is some tool which can make your life
: easier with Perl CGI programming! Which one? Show me...

     Search CPAN for "template".

 
: I say I could be really with you if I were stronger in
: Perl programming. In fact I'm just starting my programming
: life at the moment and I am waiting for some job to give a
: language direction to my career. Now I do a lot of web
: development and I've never yet come to a company which
: asked me to do it in Perl. How come? Well... I think 
: nature does its job of selection and if PHP (I'll say
: beeeuuur about ASP just for the pleasure of the troll:-))
: is more widely present for web development, it is that it's
: faster to do what you want.

    It depends, though, what you want. My clients tend to be
less sophisticated than yours in their demands. Few potential
clients have ask me for projects in specific languages. They,
like you, just want it to work as soon as possible.

    Here's where I switch to teacher mode and explain that
an approach like that will mean more expense when (not if)
you decide to change or update in the future. I then tell
them that a planned approach allows it to work now *and* in
the future. PHP, for the most part, provides answers that
promote poor programming skills. Much the same as early
programming in perl.

    It is my responsibility as a contractor or consultant
to sell appropriate products to my customers. If that means
educating them along the way, then that it what I must do. I
am the expert, not my customer. If their expertise were in
programming they wouldn't call on me.


: I think people should concentrate more around one website
: and make more documentation about Perl. Also, if that
: doesn't exist, somebody should make something to be able
: to embed Perl into html instead of embedding html into Perl.

    I believe the HTML::Mason module does this.


: Once this is done, I'm sure Perl would just be light like
: a feather and solid as a tank in the same time (and then
: beat PHP on its own ground). I doubt this would happen
: fast enough to catch up PHP on its ground. I hope so
: however.

    Actually, I think it happened *before* PHP became
popular.


: > Thoughts, feelings, pros, cons, pummeling?
: 
: Thanks for asking. The same applies to my answers.

    Not to mine, Bucko! I am always right and disagreeing
with me will lead to dire consequences.


Charles K. Clarkson
-- 
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
254 968-8328






--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to