I am sure that there is something out there but before I learn Perl I thought I would ask. Here is what I need: I need a script or program to substitute string values in an xml file from a pair definition file
running the script on the original file would generate a new file where every occurrence of dog would be replaced by cat and elephant by baby and so on.
$
$ # the definition file "f32.def"
$
$ cat f32.def
dog cat
elephant baby
$
$ # the data file "f32"
$
$ cat f32
this line has the word dog in it
this is the second line
this line has one elephant and another elephant in it
and one more elephant here
one dog and another dog and yet another dog here
the last line of this file...
$
$ # the Perl one-liner
$
$ perl -lne '$#ARGV == 0 ? {/^(\w+)\s+(\w+)$/ and $x{$1}=$2} : print join " ", map {$x{$_} // $_} split' f32.def f32
this line has the word cat in it
this is the second line
this line has one baby and another baby in it
and one more baby here
one cat and another cat and yet another cat here
the last line of this file...
$
$