Index: trunk/ippScripts/scripts/ipp_serial_chip.pl
===================================================================
--- trunk/ippScripts/scripts/ipp_serial_chip.pl	(revision 14492)
+++ trunk/ippScripts/scripts/ipp_serial_chip.pl	(revision 15474)
@@ -38,5 +38,5 @@
 
 # Phase 2 imfile processing
-my $list;
+my @whole;			# The whole list for processing
 {
     my $command = "$chiptool -pendingimfile -dbname $dbname"; # Command to run
@@ -44,25 +44,40 @@
 	run( command => $command, verbose => 1 );
     die "Unable to get phase 2 imfile list: $error_code\n" if not $success;
-    $list = parse_md_list( $mdcParser->parse( join( '', @$stdout_buf ) ) ) or
-	die "Unable to parse output from chiptool.\n";
+    my @whole = split /\n/, join( '', @$stdout_buf );
 }
 
-foreach my $item (@$list) {
-    my $chip_id = $item->{chip_id};
-    my $exp_id = $item->{exp_id};
-    my $exp_tag = $item->{exp_tag};
-    my $camera = $item->{camera};
-    my $class_id = $item->{class_id};
-    my $uri = $item->{uri};
-    my $reduction = $item->{reduction};
-    
-    my $command = "$chip --chip_id $chip_id --exp_id $exp_id --exp_tag $exp_tag --class_id $class_id --uri $uri --dbname $dbname --camera $camera";
-    $command .= " --reduction $reduction" if defined $reduction;
-    $command .= " --no-op" if defined $no_op;
-    $command .= " --no-update" if defined $no_update;
-    $command .= " --workdir $workdir" if defined $workdir;
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-	run( command => $command, verbose => 1 );
-    die "Unable to do phase 2 processing on $chip_id $class_id: $error_code\n" if not $success;
+my @single = ();
+
+while ( scalar @while > 0 ) {
+    my $value = shift @whole;
+    push @single, $value;
+    if ($value =~ /^\s*END\s*$/) {
+	push @single, "\n";
+	
+	my $list = parse_md_list( $mdcParser->parse( join( "\n", @single ) ) ) or
+	    die "Unable to parse output from chiptool.\n";
+	    
+	foreach my $item (@$list) {
+	    my $chip_id = $item->{chip_id};
+	    my $exp_id = $item->{exp_id};
+	    my $exp_tag = $item->{exp_tag};
+	    my $camera = $item->{camera};
+	    my $class_id = $item->{class_id};
+	    my $uri = $item->{uri};
+	    my $reduction = $item->{reduction};
+	    
+	    my $command = "$chip --chip_id $chip_id --exp_id $exp_id --exp_tag $exp_tag --class_id $class_id --uri $uri --dbname $dbname --camera $camera";
+	    $command .= " --reduction $reduction" if defined $reduction;
+	    $command .= " --no-op" if defined $no_op;
+	    $command .= " --no-update" if defined $no_update;
+	    $command .= " --workdir $workdir" if defined $workdir;
+	    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+		run( command => $command, verbose => 1 );
+	    die "Unable to do phase 2 processing on $chip_id $class_id: $error_code\n" if not $success;
+	}
+
+	@single = ();
+
+    }
 }
 
