$str = qq~This <1>contains<2> both text and <3>html<4>.~; $html = { 1 => 'b', 2 => '/b', 3 => 'a href="http://www.w3c.org"', 4 => '/a' }