This is totally overkill for what you want but it's a nice approach for converting HTML to XHTML and that's the subtext of your original question.
use strict; use warnings; use XML::LibXML; my $raw = do { local $/; <DATA> }; my $parser = XML::LibXML->new; $parser->recover_silently(1); my $doc = $parser ->parse_html_string("<div>$raw</div>"); my $wrapper = [ $doc->findnodes("//body/div") ]->[0]; print $_->serialize(1) for $wrapper->childNodes; exit 0; __DATA__ All content is in a variable like this...<br> <br> <a href="http://www.somedomain.com/index.cgi?page=home&var=1&no=2&so=f +orth&so=on">
You end up with-
All content is in a variable like this...<br/><br/><a href="http://www.somedomain.com/index.cgi?page=home&var=1&no=2&so=forth&so=on">In reply to Re: Switching out characters inside links
by Your Mother
in thread Switching out characters inside links
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |