I have a really bad feeling that this is probably the wrong spot, but I
can't think of the right one, so please don't flame me!

I am using perl to write a database report on the web.  At the same time, I
want to give the punters the option of downloading it as a text delimited
file for their own databases.

So far, so good.  The relevant code I am using is as follows:

while (@rec =  $stmt->fetchrow_array)
{
 local ($ord_id, $order_date2, $amount, $trans_status, $firstname, $surname)
= @rec;
 $tablebody .=
"<tr><td>$ord_id</td><td>$order_date2</td><td>$amount</td><td>$trans_status<
/td><td>$firstname $surname</td> </tr>";
 $dataline .= " $ord_id | $order_date2 | $amount | $trans_status |
$first_name $surname \n";
}
# want to record this in a text file

 local($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime($time);
 local($reportfilename) =
$reportPrefix.$merchant_id."-".($year+1900)."-".substr("00".($mon+1),-2,2)."
-".substr("00".$mday,-2,2).".txt";

if (open(LOGFILE,">>".$reportfilename))
{
  print LOGFILE join(",",$dataline)."\n";
  close(LOGFILE);
}
# we need to replace /usr/local/apache with the webserver id for a print out
$server = "..\/..";

$reportfilename =~ s/\/usr\/local\/apache\/client\/htdocs/$server/;


And that all works fine.  The problem is whenever I actually link to it, it
comes up within the webbrowser, not as a download.  I know this ia a
particularly simple problem, and I could possibly get about it by making it
some obscure extension, but I was wondering if there was any "proper" way to
do this?

(Oh, and please tell me if there are any horrible bits in my code)

Thanks a lot, and again, I'm sorry if this is the wrong spot.

Di> 

Reply via email to