Do not you know a method to carry out the following code like php?
<html>
<?perl
print( 'test' );
?>
</html>
Do not you know a method to carry out the following code like php?
<html>
<?perl
print( 'test' );
?>
</html>
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>
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.
While you can embed Perl directly into a Template Toolkit file:
[% 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>