We are using a tiny perl script that receives an xml "string" as it's argument, which then creates an xml file from the string it receives so that it can be passed on to our workflow server. The problem is that we are getting some odd characters in one of our incoming xml fields that I would like the perl script to get rid of before it creates the xml. Here is what I have:
#get rid of the bad doct characteres
if ($ARRGH =~ /<className>ibZtfacr008_chg<\/className>/) {
$ARRGH =~ s/<doct>Customer trans\.(.*)<\/doct>/<doct>Customer tran
+s\.<\/doct>/g;
}
and as an example, here's what $ARRGH would contain:
<event>
<className>ibZtfacr008_chg</className>
<oldvalue>
<x>foo</x>
<y>bar</y>
<doct>Customer trans. garbage</doct>
</oldvalue>
<newvalue>
<x>bar</x>
<y>foo</y>
<doct>Customer trans. garbage</doct>
</newvalue>
</event>
This looks fine to me, but what I end up getting is that it finds the first doct tag, finds the Customer Trans. string, but then it ignores the first (matching) closing doct tag and goes all the way to the newvalue's closing doct tag; deleting everything in between, instead of just replacing both instances of doct with the correct information. And to me it seems like i have to use the (.*) parameter because the length of the garbage that I want to get rid of varies in that tag, but I know that has to be what's causing my problem.
Now I'm a complete newb when it comes to perl, as I don't use it whatsoever, except for in this case (this is my first and only perl script :) So please if you answer the question be very explicit in the details of what to change so that I know what you're doing. Thanks!
Brian Newtz