Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Embeding Perl in HTML the PHP way

by greengaroo (Hermit)
on Sep 13, 2012 at 13:36 UTC ( #993492=note: print w/replies, xml ) Need Help??

in reply to Embeding Perl in HTML the PHP way

When I first started learning and programming Perl, back in 1999, I was doing exactly what you want to do!

If you are using Apache Web Server, please take a look at ePerl, Apache::ePerl and OSSP eperl. I think you will need mod_perl too.

Basically what you want to do is add something like this do your httpd.conf file:

<Files ~ "/usr/local/apache/htdocs/.+\.iphtml$"> Options +ExecCGI SetHandler perl-script PerlHandler Apache::ePerl </Files>

This will make Apache pre-parse the .iphtml files and interprets any embedded Perl scripts. Basically, your .iphtml files are HTML files with Perl script blocks. Note that the extension of the files could be anything you want, even .html but keep in mind this means all .html files would be pre-parsed, even if they don't contain embedded Perl.

So this is what a Perl script blocks would look like:

<html> <body> <? print 'Hello World!<br/>'; !> </body> </html>

Pretty close to PHP, hey? I think you can even change the embedded block delimiters to whatever you want with Apache::ePerl module configuration.

I remember, I even created websites using embedded Perl inside XML files back in the days! I was using AxKit! But it as been decommissioned in 2009.

Good luck!

There are no stupid questions, but there are a lot of inquisitive idiots.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://993492]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2017-06-28 03:56 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (622 votes). Check out past polls.