perl & heredoc to create xml



I have a perl script that runs a sql query to a temp file, what I need
to do is take that temp file and pull data to make an xml file.
So there are 1000 lines in this file, so I would need 1000 xml files.
I can get the sql to work...
But, I need to input the account information into an XML, where the
ticket number is.

my $fin_tck = "/home/fin_tck";
chdir ("$fin_tck");

my $tempFile = "$fin_tck/fin.tmp.$$";

my $command = <<EOF;
sqlplus -s $oraUser/$oraPass\@$ENV{'ORACLE_SID'} <<EOR>$tempFile
set heading off
set termout off
set linesize 807
set space 0
set wrap off
set feedback off
set pagesize 7010
SELECT tn||','||ticket_number||','||rcd
FROM vt_table
quit
EOF
system($command);

chomp( my $date = `date '+%Y%B%d%H'` );
open( TEMP, "$tempFile" );

while (<TEMP>) {
chomp;
s/\s+/,/g; # remove trailing whitespace
my($tn,$account,$related) = split(",", $_);
print OUT <<EOF;

<?xml version="1.0" encoding="ISO-8859-1"?><External2AC
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:noNamespac
eSchemaLocation="ext2ac.xsd">
<TroubleTicket action="finalize" type="ticket">
<KeyInfo>
<TicketNumber>$account</TicketNumber>
</External2AC>
EOF
}

close OUT, AC_OUT;
close TEMP;
unlink($tempFile);

.