Mathematica 8 has functions for this:
ImageAlign[img1, img2, "Transformation" -> "Translation"] FindGeometricTransform[img1, img2, "Transformation" -> "Translation"]
By setting the Transformation option to Translation, you guarantee that the result conversion will not have any βdistortionsβ that you mention.
Additional examples in the documentation:
http://reference.wolfram.com/mathematica/ref/ImageAlign.html
http://reference.wolfram.com/mathematica/ref/FindGeometricTransform.html
I know that you can associate Mathematica with perl, but I have not tried it yet.
EDIT: Using the link you submitted, I came up with the following. The only problem is that you need to specify the size of the output in advance --- NB I tried only the first 10 images.
directory = "~/Downloads/done/"; files = FileNames["*.bmp", directory]; canvas = ImagePad[Import[files[[1]]], {{100, 100}, {500, 100}}, Transparent]; Do[ i = Import[f]; fun = FindGeometricTransform[canvas, i, "Transformation" -> "Translation"]; If[ Head@fun === FindGeometricTransform, Continue[] ]; canvas = ImageCompose[ canvas, ImagePerspectiveTransformation[i, fun[[2]], DataRange -> Full, PlotRange -> Transpose[{{0, 0}, ImageDimensions[canvas]}], Padding -> Transparent], {1, 1, -1}], {f, files[[;; 10]]}]
