Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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

( #43365=categorized question: print w/ replies, xml ) Need Help??
Contributed by Anonymous Monk on Nov 26, 2000 at 17:00 UTC
Q&A  > HTTP and FTP clients


Answer: how can I put together my html code and perl script?
contributed by jreades

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.

Answer: how can I put together my html code and perl script?
contributed by Ovid

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.

Answer: how can I put together my html code and perl script?
contributed by t0mas

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

Please (register and) log in if you wish to add an answer



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others surveying the Monastery: (11)
    As of 2014-07-29 19:41 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (226 votes), past polls