why not have perl first sort the files from each directory
first report any files in one that are not in other
and then any files in the other that are not in the first.
then with the files that are the same, one by one,
run 'diff' and capture the output for each file.
diff is made for that kinda thing!
diff also has the ability to compare directory vs directory.