Index: other-projects/nightly-tasks/diffcol/trunk/diffcol/diffcol.pl
===================================================================
--- other-projects/nightly-tasks/diffcol/trunk/diffcol/diffcol.pl	(revision 28067)
+++ other-projects/nightly-tasks/diffcol/trunk/diffcol/diffcol.pl	(revision 28071)
@@ -699,4 +699,5 @@
 		$gsdlhome_re = ".*" unless $$ENV{'GSDLHOME'};
 		my $tmpfile_regex = "<Metadata name=\"URL\">http://$gsdlhome_re/tmp/([^\.]*)(\..{3,4})</Metadata>"; # $gsdlhome/tmp/randomfilename.html, file ext can be 3 or 4 chars long	
+		
 		if($test_contents =~ m@$tmpfile_regex@) {			
 			# found a match, replace the tmp file name with "random", keeping the original file extension 
@@ -706,23 +707,27 @@
 			my $new_tmp_filename = "random";			
 			
-			$tmpfile_regex = "(<Metadata name=\"(URL|UTF8URL|gsdlconvertedfilename|OrigSource)\">(http://)?)($gsdlhome_re)?(/tmp/)?$old_tmp_filename($ext</Metadata>)";
+			## The following does not work in the Multimedia collection, since there's a subfolder to tmp (the timestamp folder) which contains the output file.
+			#$tmpfile_regex = "(<Metadata name=\"(URL|UTF8URL|gsdlconvertedfilename|OrigSource)\">(http://)?)($gsdlhome_re)?(/tmp/)?$old_tmp_filename($ext</Metadata>)";
+			$tmpfile_regex = "(<Metadata name=\"(URL|UTF8URL|gsdlconvertedfilename|OrigSource)\">(http://)?)($gsdlhome_re)?(/tmp/)?.*?($ext</Metadata>)";
 			if($5) { 
-				$test_contents =~ s@$tmpfile_regex@$1$5$new_tmp_filename$6@g;
+				$test_contents =~ s@$tmpfile_regex@$1$5$new_tmp_filename$6@mg;
 			} else { # OrigSource contains only the filename
-				$test_contents =~ s@$tmpfile_regex@$1$new_tmp_filename$6@g;
+				$test_contents =~ s@$tmpfile_regex@$1$new_tmp_filename$6@mg;
 			}
 			
 			# modelcol used a different gsdlhome, but also a tmp dir, so make the same changes to its random filename			
-			$tmpfile_regex = "(<Metadata name=\"(URL|UTF8URL|gsdlconvertedfilename|OrigSource)\">(http://)?)(.*)?(/tmp/)?.*($ext</Metadata>)";
+			$tmpfile_regex = "(<Metadata name=\"(URL|UTF8URL|gsdlconvertedfilename|OrigSource)\">(http://)?)(.*)?(/tmp/)?.*?($ext</Metadata>)";
 			if($5) { 
-				$model_contents =~ s@$tmpfile_regex@$1$5$new_tmp_filename$6@g;
+				$model_contents =~ s@$tmpfile_regex@$1$5$new_tmp_filename$6@mg;
 			} else { # OrigSource contains only the filename
-				$model_contents =~ s@$tmpfile_regex@$1$new_tmp_filename$6@g;
+				$model_contents =~ s@$tmpfile_regex@$1$new_tmp_filename$6@mg;
 			}
 		}
 		
 #		my $savepath = &getcwd."/../"; # TASK_HOME env var does not exist at this stage, but it's one level up from current directory		
-#		&gdbdiff::print_string_to_file($model_contents, $savepath."model_doc.xml");
-#		&gdbdiff::print_string_to_file($test_contents, $savepath."test_doc.xml");
+#		if($strModel =~ m/(HASH010d.dir)/) { # list the HASH dirs for which you want the doc.xml file generated
+#		&gdbdiff::print_string_to_file($model_contents, $savepath."$1_model_doc.xml");
+#		&gdbdiff::print_string_to_file($test_contents, $savepath."$1_test_doc.xml");
+#		}
 		
 		$strResult = diff \$model_contents, \$test_contents, { STYLE => "OldStyle" };
Index: other-projects/nightly-tasks/diffcol/trunk/diffcol/gdbdiff.pm
===================================================================
--- other-projects/nightly-tasks/diffcol/trunk/diffcol/gdbdiff.pm	(revision 28067)
+++ other-projects/nightly-tasks/diffcol/trunk/diffcol/gdbdiff.pm	(revision 28071)
@@ -220,6 +220,22 @@
 		#$model_text =~ s@\[http://.*/tmp/.*(\..{3,4})\]@tmp/random$1@mg;
 		
-		$test_text  =~ s@\[http://[^\n]*?/tmp/.*?(\..{3,4})\]\n<section>([^\n]*?)\n@tmp/random$1\n<section>$2\n@sg;
-		$model_text =~ s@\[http://[^\n]*?/tmp/.*?(\..{3,4})\]\n<section>([^\n]*?)\n@tmp/random$1\n<section>$2\n@sg;
+		$test_text  =~ s@\[http://[^\n]*?/tmp/.*?(\..{3,4})\]\n<section>([^\n]*?)\n@[tmp/random$1\n<section>$2]\n@sg;
+		$model_text =~ s@\[http://[^\n]*?/tmp/.*?(\..{3,4})\]\n<section>([^\n]*?)\n@[tmp/random$1\n<section>$2]\n@sg;
+		
+		# need to re- sort the keys, now that the absolute paths to tmp locations has been removed
+		# so that we get the tmp files in the same order in both model and test collections
+		
+		# http://stackoverflow.com/questions/1909262/how-can-i-pipe-input-into-a-java-command-from-perl
+		open PIPE, "| txt2db model.gdb";
+		print PIPE "$model_text";
+		close(PIPE);
+		open PIPE, "| txt2db test.gdb";
+		print PIPE "$test_text";
+		close(PIPE);
+		
+		$model_cmd = " db2txt -sort model.gdb 2>&1";
+		$test_cmd  = "db2txt -sort test.gdb 2>&1";
+		$model_text = readin_gdb($model_cmd);
+		$test_text = readin_gdb($test_cmd);
 	}	
 
