How can I make the following script make an output to a file and not just to the screen?
/Mats
@FieldNames = $O->FieldNames();
$Cols = $#FieldNames + 1;
$Cols = 8 if ($Cols > 8);
$FmH = "format Test_10_Header =\n";
$FmH2 = "";
$FmH3 = "";
$FmB = "format Test_10_Body = \n";
$FmB2 = "";
for ($iTemp = 0; $iTemp < $Cols; $iTemp++){
$FmH .= "@" . "<" x (80/$Cols - 2) . " ";
$FmH2 .= "\$FieldNames[$iTemp],";
$FmH3 .= "-" x (80/$Cols - 1) . " ";
$FmB .= "@" . "<" x (80/$Cols - 2) . " ";
$FmB2 .= "\$Data{\$FieldNames[$iTemp]},";
}
chop $FmH2;
chop $FmB2;
eval"$FmH\n$FmH2\n$FmH3\n.\n";
eval "$FmB\n$FmB2\n.\n"; $~ = "Test_10_Header";
write();
$~ = "Test_10_Body";
# Fetch the next rowset
while($O->FetchRow()){
undef %Data;
%Data = $O->DataHash();
write();
}
print "\n\tNo more records available.\n";
}else{
$Failed{'Test 10'} = "Sql(): " . $O->Error();
}
$O->Close();
/Mats
Code:
if (! $O->Sql($mySql)){ @FieldNames = $O->FieldNames();
$Cols = $#FieldNames + 1;
$Cols = 8 if ($Cols > 8);
$FmH = "format Test_10_Header =\n";
$FmH2 = "";
$FmH3 = "";
$FmB = "format Test_10_Body = \n";
$FmB2 = "";
for ($iTemp = 0; $iTemp < $Cols; $iTemp++){
$FmH .= "@" . "<" x (80/$Cols - 2) . " ";
$FmH2 .= "\$FieldNames[$iTemp],";
$FmH3 .= "-" x (80/$Cols - 1) . " ";
$FmB .= "@" . "<" x (80/$Cols - 2) . " ";
$FmB2 .= "\$Data{\$FieldNames[$iTemp]},";
}
chop $FmH2;
chop $FmB2;
eval"$FmH\n$FmH2\n$FmH3\n.\n";
eval "$FmB\n$FmB2\n.\n"; $~ = "Test_10_Header";
write();
$~ = "Test_10_Body";
# Fetch the next rowset
while($O->FetchRow()){
undef %Data;
%Data = $O->DataHash();
write();
}
print "\n\tNo more records available.\n";
}else{
$Failed{'Test 10'} = "Sql(): " . $O->Error();
}
$O->Close();