Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

What is the best tool to embed perl in HTML?

by Anonymous Monk
on Aug 02, 2000 at 06:17 UTC ( [id://25647]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question: (cgi programming)

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?

Originally posted as a Categorized Question.

Replies are listed 'Best First'.
Re: What is the best tool to embed perl in HTML?
by gregorovius (Friar) on Aug 03, 2000 at 08:07 UTC
    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>
Re: What is the best tool to embed perl in HTML?
by jreades (Friar) on Aug 22, 2000 at 17:55 UTC

    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?

Re: What is the best tool to embed perl in HTML?
by Crayman (Acolyte) on Aug 29, 2000 at 04:01 UTC
    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.
Re: What is the best tool to embed perl in HTML?
by perrin (Chancellor) on Aug 15, 2001 at 09:59 UTC
Re: What is the best tool to embed perl in HTML?
by lindex (Friar) on Aug 02, 2000 at 20:05 UTC
    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>
Re: What is the best tool to embed perl in HTML?
by cfreak (Chaplain) on Aug 15, 2001 at 18:09 UTC

    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

Re: What is the best tool to embed perl in HTML?
by Corion (Patriarch) on Aug 02, 2000 at 12:14 UTC
Re: What is the best tool to embed perl in HTML?
by Anonymous Monk on Mar 14, 2004 at 10:58 UTC
    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.)
      Thank you for the tip.

      It is more probable that you have SSI. So, index.shtml would do.

      If you put an onLoad= attribute that calls a JavaScript you could also call your perl script and embed it with a document.write command.

      You could redirect an index.html to your perl script. And in it use a template to embed your output in an html page that would appear as a result of your script.

Re: What is the best tool to embed perl in HTML?
by sase (Initiate) on Aug 27, 2000 at 09:24 UTC
    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
Re: What is the best tool to embed perl in HTML?
by Maclir (Curate) on Aug 29, 2000 at 08:46 UTC
    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.

Re: What is the best tool to embed perl in HTML?
by tphyahoo (Vicar) on Feb 23, 2005 at 16:10 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-03-29 14:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found