Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I put inline perl code in html, like php?

Tags:

html

perl

Do not you know a method to carry out the following code like php?

<html>
<?perl
print( 'test' );
?>
</html>
like image 210
freddiefujiwara Avatar asked Jul 30 '09 05:07

freddiefujiwara


2 Answers

using HTML::Mason:

<%perl>
use Date::Calc;
my @today  = Date::Calc->Today();
my $str = "$today[0]-$today[1]-$today[2]";
</%perl>

<html>
<body>
Today is <%$str %>
</body></html>

Apache Config:

PerlModule HTML::Mason::ApacheHandler
<Location /usr/local/apache/htdocs/mason>
SetHandler perl-script
PerlHandler HTML::Mason::ApacheHandler
</Location>
like image 85
bb. Avatar answered Nov 06 '22 01:11

bb.


The syntax is a little different, but that's the approach used by HTML::Mason.

Personally, I prefer a templating system that encourages more separation of code and presentation. Template Toolkit does that while allowing flexibility to do just about anything you'd ever want to do.

like image 43
ysth Avatar answered Nov 06 '22 00:11

ysth