I would like to be able to output into a file the result set from two sql tables. i.e

I call a stored proc that basically does:-
select * from table 1
select * from table 2

My perl code only displays the contents of table 1 and not both.

my $process_kpi = 'exec build_kpi';
$sth = $dbh->prepare($process_kpi);
my $results = $sth->fetchall_arrayref;

open OUT, ">$rfile" or die "Can't open $rfile. $!\n";

print OUT join(",",@header) . "\n";

foreach my $rec ( @{$results} ) {
foreach my $column (@{$rec}) {
if (!$column) {
print OUT " ";
} else {
print OUT $column;
print OUT ",";
print OUT "\n";

close OUT;

Any ideas how I can get both tables into the file ?