Mathematica 8 features functions to do that:
ImageAlign[img1, img2, "Transformation" -> "Translation"]
FindGeometricTransform[img1, img2, "Transformation" -> "Translation"]
By setting the option "Transformation" to "Translation" you are guaranteed that the result transformation will not have any of the "distortions" you are mentioning.
More examples in the documentation:
http://reference.wolfram.com/mathematica/ref/ImageAlign.html
http://reference.wolfram.com/mathematica/ref/FindGeometricTransform.html
I know one can link Mathematica to perl, but I have not tried it yet.
EDIT: Using the link you sent, I came up with the following. The only problem is that you need to specify in advance the size of the output---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]]}]