Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

how can I put together my html code and perl script?

by Anonymous Monk
on Nov 26, 2000 at 17:00 UTC ( [id://43365]=perlquestion: print w/replies, xml ) Need Help??

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

  • Comment on how can I put together my html code and perl script?

Replies are listed 'Best First'.
Re: how can I put together my html code and perl script?
by jreades (Friar) on Nov 27, 2000 at 22:47 UTC

    There are several different alternatives, and the correct answer depends on your needs and capabilities. Off the top of my head I can think of:

    1. HTML::Mason -- for a full Perl-based solution I'd have trouble believing there's a better system out there. Mason requires mod_perl and a good ten to fifteen modules to run correctly, but is well worth the effort. Aside from the more traditional ASP-style embedded Perl (using <% an_expression %>), the Mason development team has recently added object-like features and autohandlers that enable you to thoroughly seperate formatting from content and make the system more JSP-like (not a big deal if you only have to maintain five to twenty pages, but a life saver if you have to maintain five or fifty times that amount). I'm a huge fan of this system and you can see what I've been up to here. For reference, here's the home page code, the entire page, and you can check it against the source in the browser to see what kind of advantages we're talking about in terms of maintainability and ease of updating (e.g. allowing someone else to do without worrying that they'll break everything):
      <table border="0" cellpadding="3" cellspacing="4"> <tr> <td colspan="2"><h2><font color="FF9933">Latest Company News</ +font></h2></td> </tr> <& /utils/press/last_releases, last=>2, get=>'press' &> </table> <br> <p>Cyber Dialogue is the leading Analytical eCRM provider.<snip></p> <p>Cyber Dialogue's fully hosted solution<snip></p> <%attr> type => 'index' windowTitle => 'Cyber Dialogue <snip>' pageTitle => '' description => 'Cyber Dialogue <snip>' keywords => 'Cyber Dialogue Inc.<snip>' </%attr>
    2. HTML--Embperl is here and although I haven't played with it at all (read: I am talking out of my a**) I believe that it offers a feature-set similar to what you'd find with an ASP system (e.g. <% embedded_code %>)
    3. Straight CGI or FastCGI -- just use in place of your .html files and dynamically serve whatever you want

    And that's just off the top of my head... You might also consider PHP -- I don't think it's as powerful as Perl (especially not for larger scale projects) but it seems to be more readily available if you don't control the box your site's being served on. They copied a lot of their ideas from Perl so it's very easy to pick up after a few quality hours with the manual.

      There is a module I found out about in the O'Reilly CGI Programming book called HTML::Template. It is maintained by the author and there is a mailing list about it. It's on CPAN.

      The goal of it is simplicity and COMPLETE separation of code and HTML.

      Seems pretty cool to me, although not targeted for bigger projects like Mason is.

Re: how can I put together my html code and perl script?
by Ovid (Cardinal) on Nov 26, 2000 at 19:00 UTC
    Your question is a bit vague, but I am assuming you're asking the best way to use perl to present HTML documents. Check out Template Toolkit, or the simple (but easier)HTML::Template. Also, you can read through lesson one of my online CGI course which gives simple demonstration of HERE documents.
Re: how can I put together my html code and perl script?
by t0mas (Priest) on Nov 27, 2000 at 14:19 UTC
    If your target system is aimed for Apache, the Apache::ASP module lets you embed your perl scripts in html. It uses the ASP object model which gives you request, response, session, application and server objects to use in your code. The Apache::ASP project page can be found here

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-16 06:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found