Gossamer Forum
Quote Reply
output
How can I make the following script make an output to a file and not just to the screen?

/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();
Quote Reply
Re: [Mats] output In reply to
Well instead of just printing, open a file and print to the file handle.

http://www.perldoc.com/perl5.6.1/pod/func/print.html

http://www.perldoc.com/perl5.6.1/pod/func/open.html
Quote Reply
Re: [Paul] output In reply to
Yes, but in what "variable" is the data in?

open(OUTPUT, ">c:/tmp/log.log")
print OUTPUT ????;
close(OUTPUT);

/Mats