The code above should substitute ^M with <br\/>> only with in the <Content> portion. and continuous <br\/>> should be replaced with single <br\/>> But the above code is replacing all the ^M after </Content> and before </ID>.#!/usr/bin/perl while (<DATA>) { if (/(<\w+>)/) { $flag = $1; } if($flag =~ m/<Content>/){ s/\^[A-Z]/<br\/>/g; } else{ s/\^[A-Z]//g; } print; } __DATA__ <ID>^M <Number>124^M</Number>^M <Content> Some of the week's top stories:^M EASTON AREA^M BETHLEHEM AREA^M CARBON, SCHUYLKILL AND REGION^M^M have charged his mother's boyfriend, Paul Hoffman, with third-degree m +urder. Officials said the charges were filed after an exhaustive inve +stigation that showed Miller, who died Sept. 25, had the mental capac +ity of a 12-year-old.^M </Content> ^M ^M ^M ^M ^M ^M </ID>
In reply to substitution issue by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |