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

I'm on a shared host and they don't have Embperl or Mason installed.

My script takes in a number via a post, searches a database, and outputs data in some HTML tables.

Is there any other way besides Embperl, Mason, or SSI's to embed perl into a HTML doc?

Replies are listed 'Best First'.
Re: Embedding Perl into HTML
by holli (Abbot) on Apr 24, 2005 at 06:29 UTC
Re: Embedding Perl into HTML
by cowboy (Friar) on Apr 24, 2005 at 06:13 UTC
    You can use Mason via CGI, although that would require you getting the modules installed, some of which, may need compiling.
    You might look at Text::MicroMason.
    It sounds to me though, like you mainly want to use a template for the tables, in that case, there are many templating solutions you could use. Some like Template::Toolkit, others like HTML::Template, others prefer Mason, or Embperl. There are lots of options you can just stick into your script to display the data nicely.
      I want to embed perl into the HTML because right now I have the main "index.html" as the blank search page that posts to "search.pl" and all after I do a serch I end up at "http://yourname.com/cgi-bin/search.pl?search=X" where I display all the retrieved info.

      So I'm duplicating my HTML twice, once on "index.html" and once inside "search.pl"

      I guess there must be a better way to do this. Maybe using a header and footer HTML file that is used in both docs? But I wanted to embed Perl into HTML like PHP is done.

        Look at CGI::Application in combo with HTML::Template to eliminate some of the busy stuff in the URI and allows you to use a simple index.cgi to run the flow. Here's a nice little tutorial.


        —Brad
        "The important work of moving the world forward does not wait to be done by perfect men." George Eliot
        Mason, or other things allow what you're asking. A simple fix, rather than duplicating the code, see if you can make 'search.pl' your index page. There is nothing magic about index.html, it's just in many cases, the default page shown if someone requests a directory rather than an absolute file. On most hosts you should be able to change it so that the index is whatever file you like.
Re: Embedding Perl into HTML
by kgraff (Monk) on Apr 24, 2005 at 12:13 UTC

    Pardon me for replying with a question, but why are Perl SSI's not an option? The main complication for most shared hosts is having to use a .shtml file name.

Re: Embedding Perl into HTML
by gloryhack (Deacon) on Apr 24, 2005 at 22:00 UTC
    Consider CGI::FastTemplate. If your hosting provider doesn't have it installed, you can just drop it somewhere accessible in your account's space and use lib('path/to') to get at it.
Re: Embedding Perl into HTML
by BUU (Prior) on Apr 24, 2005 at 05:59 UTC
    Sure:
    s/\{(.*)\}/$1/eg;
    (Obviously this is a pretty silly answer. But the question is fairly silly also =] )