{ $buffer = ''; $filename = ''; $line = ''; $job = ''; $temp = ''; $index_job = 0; $key = ''; $tray = ''; print LOG "$mday$mon$year $hour:$min:$sec Processing Data file, splitting Jobs.\n"; # Skip first line. #; while () { $line = $_; if ($line =~ /^(\^JOB.*)\n$/i) #if the current line is a ^job line then { $tmp = $1; #Set $tmp equal to what is in (\^JOB.*) ie: ^job PATIENTLBL -c1 -zDP7P @pieces = split(/ /, $tmp); #Split-up the entire line, on spaces, into @pieces $newjob = $pieces[0]." "."JF".$pieces[1]." ".$pieces[2]." ".$pieces[3]."\n"; #Rebuild ^job line with JF in front of jobname #print "newjob : ".$newjob; $temp = $newjob; #Assign new ^job line to $temp to create new file(s) if ($buffer ne "") #Not first job { print LOG "$mday$mon$year $hour:$min:$sec Found: $job"; $buffer_job[$index_job++] = $buffer; } $job = $temp; $buffer = $temp; }else{ $buffer .= $line; } }