Always a module for this kind of thing. It might feel like more work to set up but you will save yourself hours of learning the hard way otherwise.
You'll also need well formed block tags around your text. Strict XHTML doesn't allow naked flow tags in the body. There are a lot of ways to do this, the one I like a lot is using XML::LibXML as an XHTML filter/writer.
Semi-tested minimalist version. You'll have to manipulate/add headers and the <html/> yourself-
Yields-use strict; use warnings; use XML::LibXML; local $/ = "\n\n"; my $doc = XML::LibXML::Document->createDocument(); my $root = $doc->createElement("body"); $doc->setDocumentElement( $root ); while ( my $para = <DATA> ) { chomp $para; my $p = $doc->createElement("p"); my $txt = $doc->createTextNode( $para ); $p->appendChild($txt); $root->appendChild($p); } print $doc->serialize(1); __DATA__ Some arbitrary text > some fixed text & that's okay. XHTML is fun with L<XML::LibXML>.
Update: LibXML can be a bit daunting. Here is a quicky you can use to just get the block level (the <p/>s) tags out of the document. print $_->serialize(1), $/ for $doc->getDocumentElement->childNodes;<?xml version="1.0"?> <body> <p>Some arbitrary text > some fixed text & that's okay.</p> <p>XHTML is fun with L<XML::LibXML>. </p> </body>
In reply to Re: HTML escape char?
by Your Mother
in thread HTML escape char?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |