http://www.perlmonks.org?node_id=1232383

phoenix007 has asked for the wisdom of the Perl Monks concerning the following question:

I want to modify HTML using HTML::TreeBuilder. I was trying to parse plain text and identify urls and modify them with <a hrel="url">url</p>

If I have following line in my HTML :

<p>test1 www.google.com <a href="www.google.com">www.google.com</a> test2</p>

I want to modify it to :

<p>test1 <a href="www.google.com">www.google.com</a> <a href="www.google.com">www.google.com</a> test2</p>

Here I am facing two problems : I am not getting proper count of child contents so that I can modify them I get total_contents as 1 for p. Second problem is I am not able to insert new HTML::Element inside text of p