Leser: 1
![]() |
|< 1 2 3 4 >| | ![]() |
33 Einträge, 4 Seiten |
1
2
3
4
5
6
7
8
9
10
11
12
my %vars = (
test => "Perl",
);
my $content = "";
my @template = ("Blablabla\n", "<% test %>\n", "blablabla\n");
foreach my $row (@template) {
$row =~ s/<% ([A-Za-z0-9]+) %>/$vars{$1}/gix;
$content .= $row;
print $row;
}
$row =~ s/^<%\s*(\w+)\s*%>$/$vars{$1}/eg;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use strict;
use warnings;
use Template;
my %vars = (
test => 'Hello World!',
another_test => 'How are you?'
);
my $template = new Template;
$template->process(\*DATA, \%vars);
__END__
Content-Type: text/html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Test template</title>
</head>
<body>
<h1>[% test %]</h1>
<h3>[% another_test %]</h3>
</body>
</html>
![]() |
|< 1 2 3 4 >| | ![]() |
33 Einträge, 4 Seiten |