Hallo,
ich habe folgende index.pl:
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/perl
use warnings;
use strict;
use CGI;
use CGI::Carp 'fatalsToBrowser';
use Encode;
use File::Basename 'basename';
use FindBin;
use HTML::Element;
use Template;
my $q = CGI->new;
my $tt = Template->new(
INCLUDE_PATH => "$FindBin::Bin/templates",
FILTERS => {
literature => \&literature,
},
WRAPPER => 'wrapper.tt',
);
my $vars = {};
print $q->header( -charset => 'utf-8' );
my $default_page = 'start';
my %valid_pages = map { basename($_, '.tt') => 1 } glob "$FindBin::Bin/templates/*.tt";
my $requested_page = $q->param('page') || '';
my $page = exists $valid_pages{ $requested_page } ? $requested_page : $default_page;
my $template = "$page.tt";
$vars->{page} = $page;
my $base = $q->url( -base => 1 );
if ( $base =~ /klaus\.de/ ) {
$vars->{base} = $q->url( -base => 1 );
}
else {
if ( $q->url =~ /tmay/ ) { # spielwiese
$vars->{base} = $q->url( -base => 1 ) . '/tmay/',
}
else {
$vars->{base} = $q->url( -base => 1 ) . '/cb/',
}
}
$tt->process( $template, $vars ) || carp $tt->error();
sub literature {
my $list = shift;
my @items = split /\n\n/, $list;
my @res;
foreach my $item (@items) {
if ( $ENV{SERVER_SOFTWARE} =~ /Apache.1/ ) {
utf8::decode($item);
}
my ($title, $more) = split /\n/, $item, 2;
$title = HTML::Element->new('span', class => 'booktitle' )->push_content( $title );
push @res, HTML::Element->new('li')->push_content( $title, ['br'], $more );
}
return HTML::Element->new('ol', class => 'literature')->push_content(@res)->as_XML;
}
und möchte die Datei so um schreiben, dass beim Aufrufen automatisch auf eine andere Adresse weitergeleitet wird.
Wäre dankbar, wenn jemand mir weiterhelfen würde.
Grüße,
G.M.
Last edited: 2019-02-12 00:20:02 +0100 (CET)