in reply to Appending a file between XML markers
If you're doing anything more interesting than your stated problem, it'll be worth it to use a real XML parser instead. I recommend XML::Twig.open INPUT,"<","input.xml" or die $!; open OUTPUT,">","output.xml.tmp" or die $!; while (<INPUT>) { s/<\/markers>/$database_row<\/markers>/; # insert $database row bef +ore marker, if found on this line print OUTPUT $_; # print line to output file } close INPUT; close OUTPUT or die $!; rename "output.xml.tmp","input.xml";
|
|---|