Index: trunk/pstamp/scripts/dqueryparse.pl
===================================================================
--- trunk/pstamp/scripts/dqueryparse.pl	(revision 27874)
+++ trunk/pstamp/scripts/dqueryparse.pl	(revision 28777)
@@ -102,5 +102,5 @@
     if $extname ne "MOPS_DETECTABILITY_QUERY";
 my_die("$req_file is version $extver expecting 1", $PS_EXIT_PROG_ERROR)
-    if $extver ne 1;
+    if ($extver ne 1) and ($extver ne 2);
 
 # Set up the workdir for this query.
@@ -129,6 +129,9 @@
     $fault = $error_code >> 8;
     if ($fault == $PSTAMP_NOT_AVAILABLE) {
-	$data_to_update = (split /\n/, (join "", @$stdout_buf))[-1];	
+	unless (-e "$outdir/update_request.dat") {
+	    my_die ("Update request indicated, but unable to find actual request!", $PS_EXIT_PROG_ERROR);
+	}
     }	
+    
 }
 
@@ -158,27 +161,33 @@
     # Failed to run correctly, which means that we need to queue a job and flag data for updating.
     # Get the dependency id for the data we're requesting be updated.
-    my $dep_id = queue_update_run($req_id,$job_id,$outdir,$label,$data_to_update);
-
-    # Link this request to a job and link that job to any dependency
-    my $command = "$pstamptool -addjob -req_id $req_id -outputBase $outdir"; 
-    $command .= " -job_type detect_query -state run -fault 0";
-    $command .= " -rownum 1";
-    $command .= " -dep_id $dep_id" if $dep_id;
-
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-        run(command => $command, verbose => $verbose);
-
-    if ($success) {
-        $job_id = join "", @$stdout_buf;
-        chomp $job_id;
-        if ($job_id && -e $response_file) {
-	    # We shouldn't have a response file at this stage.
-            rename $response_file, "$outdir/response${job_id}.fits";
-        }
-        $result = 0;
-    } else {
-        warn("Unable to perform $command error code: $error_code");
-        $result = $error_code >> 8;
-    }
+    open(UPDATE_REQUEST,"$outdir/update_request.dat") || my_die ("Update request indicated, but unable to find actual request!", $PS_EXIT_PROG_ERROR);
+    while (<UPDATE_REQUEST>) {
+	my $data_to_update = $_;
+	chomp($data_to_update);
+	my $dep_id = queue_update_run($req_id,$job_id,$outdir,$label,$data_to_update);
+
+	# Link this request to a job and link that job to any dependency
+	my $command = "$pstamptool -addjob -req_id $req_id -outputBase $outdir"; 
+	$command .= " -job_type detect_query -state run -fault 0";
+	$command .= " -rownum 1";
+	$command .= " -dep_id $dep_id" if $dep_id;
+
+	my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+	    run(command => $command, verbose => $verbose);
+
+	if ($success) {
+	    $job_id = join "", @$stdout_buf;
+	    chomp $job_id;
+	    if ($job_id && -e $response_file) {
+		# We shouldn't have a response file at this stage.
+		rename $response_file, "$outdir/response${job_id}.fits";
+	    }
+	    $result = 0;
+	} else {
+	    warn("Unable to perform $command error code: $error_code");
+	    $result = $error_code >> 8;
+	}
+    }
+    close(UPDATE_REQUEST);
 }
 
