+ else {
+ # XML::DOM not available...
+ # parse the template using both hands ;)
+ #
+
+ my ($xml, $root, $template);
+ local (*FILE, $/);
+
+ open FILE, "< $filename" or croak "error while reading template file '$filename': $!";
+ $xml = <FILE>;
+ close FILE or croak "error while closing template file '$filename' after reading: $!";
+
+ ($root, $template) = ($1, $2) if ($xml =~ m|(<Template\s+[^>"]*(?:"[^"]*"[^>"]*)*>)(.*)</Template\s*>|s);
+ croak "error while parsing template file '$filename': missing root element 'Template'"
+ unless (defined $root and defined $template);
+
+ # extract meta delimiters
+ #
+ $self -> {metaon} = $1 if ($root =~ /\smetaon\s*=\s*"([^"]+)"/);
+ $self -> {metaoff} = $1 if ($root =~ /\smetaoff\s*=\s*"([^"]+)"/);
+
+ croak "missing meta defintion(s) in template file '$filename'." unless ($self -> {metaon} and $self -> {metaoff});
+
+ # don't use any other entities than " ' < > and &
+ # (while using non XML::DOM - version)
+ #
+ for ('metaon', 'metaoff') {
+ $self -> {$_} =~ s/"/"/g; $self -> {$_} =~ s/'/'/g;
+ $self -> {$_} =~ s/</</g; $self -> {$_} =~ s/>/>/g;
+ $self -> {$_} =~ s/&/&/g;
+ }