Using a Perl replace statement (s//) I'd like to modify some XML by adding an attribute to some items if missing. Here's an example :
...
<car color="red" owner="john">...</car>
<car color="green" age="3">...</car>
...
Let's say I'd like to add a default owner to ownlerless cars. I tried the following without success :
s/(<car[^>]*)(?!owner="[^"]*")(.*>)|$1 owner="steve"$2/iUg
Any help appreciated.