## Apache config # # PerlRequire /home/e/eserte/devel/Mesh.pm # SetHandler perl-script # PerlHandler Mesh::handler # package Mesh; use strict; use Apache::Constants; use XML::LibXML; sub handler { my $r = shift; my $f = $r->filename; my $p = XML::LibXML->new; my $doc = $p->parse_file($f) or die $!; my $root = $doc->documentElement; $root->setNamespaceDeclURI(undef,undef); my($body) = $root->findnodes("/html/body"); my $header = $p->parse_xml_chunk(<This is the header EOF my $footer = $p->parse_xml_chunk(<This is the footer EOF if ($body->firstChild) { $body->insertBefore($header, $body->firstChild); $body->insertAfter($footer, undef); } else { $body->insertAfter($header); $body->insertAfter($footer); } $r->send_http_header; $r->print($doc->serialize); Apache::Constants::OK(); } 1; __END__