perl -pi.bak -e" /\(baz-\d+\)/ and print 'bar=2'.$/" file