Added the perl implementation of the first math dm.