86 lines
1.5 KiB
Perl
86 lines
1.5 KiB
Perl
package http;
|
|
require Exporter;
|
|
|
|
use CGI;
|
|
|
|
use vars qw($VERSION @ISA @EXPORT);
|
|
$VERSION = 1.00;
|
|
@ISA = qw(Exporter);
|
|
###############################################################################
|
|
@EXPORT = qw/
|
|
cgi_header
|
|
html_refresh
|
|
html_title
|
|
html_header
|
|
html_body
|
|
html
|
|
|
|
/;
|
|
|
|
|
|
######## HTML Funktionen und Beispielnutzung
|
|
# my @header=(html_refresh(5, "URL"), html_title("titel"));
|
|
# my @body=("inhalt 1<br>", "inhalt 2<br>");
|
|
# my @html=html(\@header, \@body);
|
|
# foreach (@html) {
|
|
# print "$_\n";
|
|
# }
|
|
|
|
sub cgi_header {
|
|
my @a = ("Content-type: text/html","<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
|
|
return @a;
|
|
}
|
|
|
|
sub html_refresh {
|
|
my $s=shift;
|
|
my $u=shift;
|
|
my @ret = ("<meta http-equiv=\"refresh\" content=\"$s; URL=$u\">");
|
|
return @ret;
|
|
}
|
|
|
|
sub html_title {
|
|
my $a=shift;
|
|
my @ret = ("<title>$a</title>");
|
|
return @ret;
|
|
}
|
|
|
|
sub html_header {
|
|
my $a=shift;
|
|
my @a=@{$a};
|
|
my @ret;
|
|
push @ret, "<head>";
|
|
foreach (@a) {
|
|
push @ret, "$_";
|
|
}
|
|
push @ret, "</head>";
|
|
return @ret;
|
|
}
|
|
|
|
sub html {
|
|
my $h=shift;
|
|
my $b=shift;
|
|
my @h=@{$h};
|
|
my @b=@{$b};
|
|
my @ret;
|
|
push @ret, cgi_header();
|
|
push @ret, "<html>";
|
|
push @ret, html_header(\@h);
|
|
push @ret, html_body(\@b);
|
|
push @ret, "</html>";
|
|
return @ret;
|
|
}
|
|
|
|
sub html_body {
|
|
my $a=shift;
|
|
my @a=@{$a};
|
|
my @ret;
|
|
push @ret, "<body>";
|
|
foreach (@a) {
|
|
push @ret, "$_";
|
|
}
|
|
push @ret, "</body>";
|
|
return @ret
|
|
}
|
|
|
|
1;
|