########### Process the Input string ############ my $replstr ="/) { $range_rep = $1; $strFile =~ m/]+>/; $str2relpace = "$`$&"; # This is the string to be replaced if($str2relpace =~ m/<\/(.*)?>.*<\/description>/) { $desc = $&; } $desc = "\n".$desc if($desc); $` =~ m//; $elementName = $1; $eleVal=$1 if($elementName =~ m/\"(.*)\"/); # Constructing the replace string. $replstr .=$elementName." ".'location="'."$eleVal\" ". "$range_rep".'>'; # This is the replacing string $strFile =~ s/\Q$matchStr\E/$replstr$desc/g; #$strFile =~ s/<\/product><\/entity>/<\/block>/ig; print "\n\n\n The output is ================= \n $strFile \n \n ==================\n"; }