Do not you know a method to carry out the following code like php?
你不知道一个方法来执行像PHP这样的代码吗?
<html>
<?perl
print( 'test' );
?>
</html>
4 个解决方案
#1
15
using HTML::Mason:
使用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:
Apache配置:
PerlModule HTML::Mason::ApacheHandler
<Location /usr/local/apache/htdocs/mason>
SetHandler perl-script
PerlHandler HTML::Mason::ApacheHandler
</Location>
#2
7
The syntax is a little different, but that's the approach used by HTML::Mason.
语法略有不同,但这是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.
就个人而言,我更喜欢模板系统,鼓励更多的代码和表示分离。 Template Toolkit可以实现这一目标,同时允许灵活地执行您想要做的任何事情。
#3
2
There's also EmbPerl though it is not too widely used.
虽然它没有被广泛使用,但也有EmbPerl。
#4
2
While you can embed Perl directly into a Template Toolkit file:
虽然您可以将Perl直接嵌入到Template Toolkit文件中:
[% PERL %]
use Date::Calc;
my @today = Date::Calc->Today();
my $str = "$today[0]-$today[1]-$today[2]";
[% END %]
<html>
<body>
Today is [% $str %]
</body></html>
A better way is to use a Plugin:
更好的方法是使用插件:
[% USE date %]
<html>
<body>
Today is [% date.format(date.now, format = '%d-%b-%Y') %]
</body></html>
#1
15
using HTML::Mason:
使用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:
Apache配置:
PerlModule HTML::Mason::ApacheHandler
<Location /usr/local/apache/htdocs/mason>
SetHandler perl-script
PerlHandler HTML::Mason::ApacheHandler
</Location>
#2
7
The syntax is a little different, but that's the approach used by HTML::Mason.
语法略有不同,但这是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.
就个人而言,我更喜欢模板系统,鼓励更多的代码和表示分离。 Template Toolkit可以实现这一目标,同时允许灵活地执行您想要做的任何事情。
#3
2
There's also EmbPerl though it is not too widely used.
虽然它没有被广泛使用,但也有EmbPerl。
#4
2
While you can embed Perl directly into a Template Toolkit file:
虽然您可以将Perl直接嵌入到Template Toolkit文件中:
[% PERL %]
use Date::Calc;
my @today = Date::Calc->Today();
my $str = "$today[0]-$today[1]-$today[2]";
[% END %]
<html>
<body>
Today is [% $str %]
</body></html>
A better way is to use a Plugin:
更好的方法是使用插件:
[% USE date %]
<html>
<body>
Today is [% date.format(date.now, format = '%d-%b-%Y') %]
</body></html>