Re: Can I code perl inside HTML?
by arturo (Vicar) on Feb 01, 2001 at 23:45 UTC
|
Yes, but you'll need to have mod_perl installed on your webserver (which means it must be Apache -- for more on mod_perl, see this site). There are a number of modules that work under mod_perl to choose from, one that strikes me because it was posted about here today is HTML::Mason, but there's also embperl and Eperl.
You're in for a wild ride, but a rewarding one if you carry your idea through =) Philosophy can be made out of anything. Or less -- Jerry A. Fodor
| [reply] |
Re: Can I code perl inside HTML?
by dws (Chancellor) on Feb 01, 2001 at 23:51 UTC
|
If you're using IIS and keeping the .html extension isn't a requirement, you can use PerlScript. It installs with ActiveState Perl, and has a fair amount of on-line (html) documentation. I've used it on several intranet sites, and it works quite well, particularly if you need to tie into COM/ActiveX.
| [reply] |
Re: Can I code perl inside HTML?
by sierrathedog04 (Hermit) on Feb 02, 2001 at 01:17 UTC
|
Embperl, which is available here at CPAN, describes itself as being a "Perl extension for embedding Perl code in HTML documents."
Templating modules such as HTML::Template, on the other hand, can be the functional equivalent of embedding Perl inside HTML.The documentation for HTML::Template by Sam Tregar says that often a module like Embperl is overkill for the problem at hand. In some cases one only needs to embed certain Perl constructs such as loops into HTML. HTML::Template seems to provide a lower overhead way to do that, although it embeds special markup rather than Perl itself into the HTML.
I have not yet started to use HTML::Template, and I do have one reservation about starting to. Apparently it is quite limited compared to yet other tools out there, including something called the (HTML?) Toolkit. Indeed, someone on Chatterbox today told me that comparing HTML::Template to the "Toolkit" is like comparing Palm Beach Punch-Card Voting Machines to real ones.
On the other hand, my cheap-o ISP won't let me install modules directly on the server using Makefile.PL, so I want something that I can copy into my CGI-bin by hand. Anything too complicated, such as HTML-Mason, is just too much work to manually install file-by-file and directory by directory. I am hoping that something simpler like HTML::Template will fill the bill, and be superior to rolling my own templating tool which is essentially what I do now.
| [reply] |
|
|
| [reply] |
Re: Can I code perl inside HTML?
by Gloom (Monk) on Feb 01, 2001 at 23:59 UTC
|
The extension .html no matter, is just the configuration of your webserver that link .cgi , .pl ... to the perl interpreter ( or mod_perl ). You can arbritrary choose whatever extension you want. Of course, this supose you have access to the configuration files. | [reply] |
|
|
Mason is supposed to be used for embedding perl in html. I dont know any details of it, but I believe its meant to be used with mod_perl and Apache. Mason v1 was recently released. www.masonhq.com
Perhaps someone could enlighten us more about this?
| [reply] |
|
|
| [reply] |
Re: Can I code perl inside HTML?
by beppu (Hermit) on Feb 02, 2001 at 10:37 UTC
|
Just to round things out, I thought I'd mention HTML::Embperl which is comparable to HTML::Mason in that it lets you embed perl code inside HTML.
| [reply] |
Re: Can I code perl inside HTML?
by john1987 (Acolyte) on Feb 02, 2001 at 01:29 UTC
|
You can put Perl in "virtually" any extension, as long as you got your #!/usr/bin/perl coding correct, and your server supports Perl. Perl usually has 2 main extensions: .pl .cgi and .pm (.pm is Perl modules). What would be much easier is to put the html in the Perl code. This way you can avoid modules, not that it would matter but just to be quicker. If you are not sure of how to put HTML into Perl, here's a very simple code to use:
print "Content-type: text/html\n\n";
print "<html><b><u><font size=4>Yo! Wasup?</font></u></b></html>\n";
This is a VERY simple code but yet effective.
One person can change the corse of history. One person can destroy the human race. That one person is out there, I intend to find him.
My other writings. | [reply] [d/l] [select] |
|
|
True for Apache. Not true for IIS.
IIS ignores the #! line. Instead, it uses the extension to map (by way of the registry) to the executable to handle the script.
ActivePerl reads the #! line, but only to pick up arguments.
| [reply] |
A reply falls below the community's threshold of quality. You may see it by logging in.
|