Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

What is the best tool to embed perl in HTML?

( #25647=categorized question: print w/ replies, xml ) Need Help??
Contributed by Anonymous Monk on Aug 02, 2000 at 06:17 UTC
Q&A  > CGI programming


Description:

Please compare and contrast the different systems that allow one to embed PERL in html.

So far I've discovered:

  • embperl
  • HTML:Mason
  • Apache::ASP
What else is available? What are the strong points and weaknesses of each? Which do you use?

Answer: What is the best tool to embed perl in HTML?
contributed by gregorovius

I recommend HTML::Embperl. It allows code to be edited on your favorite HTML editor (e.g. Dreamweaver) at the rendered HTML level, so you have all page design and code visible at the same time (though this could be a drawback, since too much code may clutter your page as seen on your editor, but you can always create Embperl subroutines).

Another plus is that it readily integrates with DBIx::Recordset, which is a powerful layer atop DBI which simplifies access to SQL databases by, for example, tying tables to hashes. I would say that DBIx::Recordset is generally more portable than DBI and very valuable in itself.

Some other features of Embperl that I haven't seen elsewhere (my other platform has been MS/IIS/ASP/PerlScript) are:

* Automagically generated HTML tables via the $row and $col variables.
* Automatic filling of HTML forms through the %fdata hash.
* Persistant per-user data through the %udat hash (by way of Apache::Session and an SQL database).
* Persistant per-page data through the %mdat hash.
* Readily available help from it's mailing list and constant maintenance and improvements to the code by its author. <href="http://perl.apache.org/embperl">HTML::Embperl</href>

Answer: What is the best tool to embed perl in HTML?
contributed by jreades

I'm a big fan of HTML::Mason (I wrote a lynx-component in under an hour to make our site lynx/diability-accessible), but as with everything YMMV depending on what you're trying to accomplish.

For instance: I love Mason's component architecture because I have a 400+ page site to maintain and I want to be able to make a change in one place (component) and have that propagate across the site instantly, and by using components and autoloaders this (and many other fun little games) becomes not only possible but, frankly, easy.

I have to admit ignorance of the other tools, but a quick glance at some of the code above suggests (merely suggests, I've just admitted ignorance) that Embperl is doing a lot more magic on the backend that Mason or Apache::ASP. I can envision some situations where this would be a plus (rapid prototyping and deployment), and some where this would be a minus (when I want Perl to behave in a very particular way).

Only a close reading of the documentation for each will really tell you where the tradeoffs lie -- I think that Mason has some big advantages in small to mid-sized sites with a small number of staffmembers allocated to maintenance... why? Because autohandlers/components make it easy to seperate code from content and allow people to work on different pieces simultaneously through it's primitive object interface (added is 0.81 I believe), and the caching scheme seems to scale well up to 100,000 hits/month or more (but not into the millions).

I'd suspect that Embperl, because of the backend magic, might have slightly higher overhead which could become an issue at the higher end of hits/month. But maybe I'm dead wrong... anyone care to show me?

Answer: What is the best tool to embed perl in HTML?
contributed by Crayman

I have used Embperl for over a year, and I am very happy with it. Lots of the parsing stuff is in C, it runs under mod_perl and does caching so it runs VERY quickly. I especially like the way it handles sticky formfields and autogeneration of tables. Its session handling is practically transparent. It has component handling capabilities somewhat like Mason's. I have not tried them yet, but I am looking forward to it. The free support has been excellent. I don't think Gerald ever goes on vacation and an authoritative answer to your question is usually never more than a few hours away.

Answer: What is the best tool to embed perl in HTML?
contributed by perrin

I've compared these tools and a few others in my article Choosing a Templating System. I hope you find it helpful.

Answer: What is the best tool to embed perl in HTML?
contributed by lindex

Well Iam currently using Apache::ASP and its pretty cool
I have yet to find a real drawback to it :)
Examle (print env):

<html> <body bgcolor="White"> <% map { print "\$ENV{$_} = $ENV{$_}<br>\n"; } keys(%ENV); %> </body> </html>
Answer: What is the best tool to embed perl in HTML?
contributed by cfreak

I've been using HTML::Template for over a year now and absolutely could not do without it. I've looked at other solutions like EmbPerl and they are fine but HTML::Template takes a different approach. Rather than embedding perl into the HTML documement, it separates the HTML development from Perl development by adding some specialized tags to HTML to allow for simple IFs Variables and Loops.

A few Benefits that I've noticed:
  • Its easy enough on the HTML side for the clueless web designers to understand but can be used to build complex apps.
  • It allows you to quickly change HTML documents without messing with any Perl code
  • Fast. Even allows for caching of documents when using mod_perl.

Hope that helps

Answer: What is the best tool to embed perl in HTML?
contributed by Corion

I haven't used any of them, but there is also HTML::Template available. HTML::Mason and HTML::Template have been compared in The Perl Journal in a series of articles I think.

Answer: What is the best tool to embed perl in HTML?
contributed by Anonymous Monk

I could not find an easy one line solution for embedding the output easily into html.

if your server supports php, you could do this:

Create a new text document-->Open it-->put this one line of code into it:

<? virtual("/cgi-bin/foldername/scriptname.cgi"); ?>

--> Save the file as "scrtest.php" (We sometimes need to use the "Double Quotes" to make sure your editor does not put a .txt or .doc on the end of the file extension)

Upload to webserver, then go to Internet Explorer Address bar --> www.yoursite.com/scrtest.php

If your thinkin What about the rest of my HTML, you could use this:

<html><body>
Your Html before the script output gets called

<? virtual("/cgi-bin/folder/scriptname.cgi"); ?>

Your HTML After the script output has been called</body></html>

(again it will have to be saved as a .php page. index.php if you want it as the default document in a folder (rename the old index.html to indexold.html; it may check for this file first when a page is not specified in a web address.)

Answer: What is the best tool to embed perl in HTML?
contributed by sase

I'm not sure exactly where you're going with this.. but I was thinking.. What happened to SSI? Loading a CGI from a page to provide dynamic content.. having it print out whatever you want to change.. ? Or am I just totally off target here -Sase

Answer: What is the best tool to embed perl in HTML?
contributed by Maclir

My view is that for simple, one off pages, knock it up with CGI.pm - that makes things quick and easy. However, it has the disadvantage that your program logic is interspersed with the HTML. In fact, the HTML is not immediately apparent, since it is all generated by CGI calls.

Embperl is good for small to medium sites, and it is possible to implement a set of components with it. What I like about Embperl is that the programs are structured just as your static HTML would be.

Although I haven't used it, once the site gets reasonable large, Mason would be the way to go.

Answer: What is the best tool to embed perl in HTML?
contributed by tphyahoo

There's a lot to choose from. You may want to have a look at Survey of Surveys on HTML Templating systems where I tried to "sort out the technology soup."

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 exploiting the Monastery: (7)
    As of 2014-07-28 05:19 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (186 votes), past polls