rocknbil - 4:38 pm on Mar 18, 2011 (gmt 0)
There are two ways off the top of my head that will work for this, but it's not actually embedding perl "in the page."
The first and most obvious:
- make sure you can set .html extensions to be parsed by server side includes, OR change your html extensions to .shtml so they will be parsed by server side includes.
- Wherever you'd include "perl output," do this.
<!--#include virtual="/path/to/yourscript.pl" -->
or (some servers won't let you exec)
<!--#exec cmd="perl /path/to/yourscript.pl"-->
<!--#exec cgi="/path/to/yourscript.pl" -->
and you can even pass parameters; yourscript.pl would accept parameters via @ARGS
<!--#include virtual="/path/to/yourscript.pl blah=1 bleah=2" -->
or query string . . .
<!--#include virtual="/path/to/yourscript.pl?blah=1&bleah=2" -->
The advantage of the second is if you have a script that will be included OR called from the web it will work in either case without modification.
The second and probably more manageable method, though it would take a bit more programming, is to use the actual HTML files as "templates" and use "markers" where you would expect perl output. Looks like Mason is doing something "like" this, another is Template::Toolkit (which may already be installed in your environment.)
The advantage of this method is you don't need multiple requests for various scripts; you call a single script and it parses out the page as a template, replacing the markers with your data.