COGEF Calculations Using DMol3

I am interested in performing COGEF calculations using DMol3. Essentially we are taking a molecule, constraining the distance of 2 atoms in particular, and then we run a Geometry Optimization followed by an Energy calculation. Then we take these energy calculations, expand the distance of some atoms and re-run a new Geometry Optimization followed by Energy which is based on the previous calculation. Does someone currently know of Perl Script that can accomplish this tedious task or at least of a subroutine that can do part of this?