Content-Type: application/force-download 试试 这个 (我没试过)
在 2010年5月7日 上午10:11,wd <[email protected]> 写道: > 打印前设置好 header > > 在 2010年5月7日 上午6:54,camelbbs <[email protected]>写道: >> >> 我有一个小程序,需要用perl CGI 输出.txt >> >> index.html: >> [code] >> <html> >> <head><title>correlation database</title></head> >> <body> >> <form action="../cgi-bin/deal.cgi" method="post"> >> input gene:<br> >> <textarea name="gene" cols ="50" rows = "5"></textarea> >> <br> >> select:<br> >> <input type="checkbox" name="set1" value ="human-calgb-81s" >human 81 >> calgb samples<br> >> <br> >> <input type="submit" value="submit"> >> </form> >> </body> >> </html> >> [/code] >> >> 然后 deal.cgi是对传入的两个参数 gene 和 set1 进行处理,处理之后想直接生成一个txt 文件,而不是在网页上显示出来,应该如 >> 何写这个deal.cgi呢? >> >> 我的deal.cgi是这样写的: >> [code] >> #!D:/perl/bin/perl >> use strict; >> use CGI; >> >> print "Content-type:text/plain\n\n"; >> >> my $cgi=new CGI; >> my $set1=$cgi->param("set1"); >> my $gene=$cgi->param("gene"); >> my $mir=$cgi->param("mir"); >> my $file='correlation-'.$set1; >> my $dir='all-correlation-result'; >> >> open(FILE,'../htdocs/'.$dir."\\".$file) or die; >> while(my $line=<FILE>){ >> chomp $line; >> my @dd=split /\t/,$line; >> my @tmp=split /--/,$dd[1]; >> if($tmp[1] eq $gene){ >> print "$line\n"; >> } >> } >> close(FILE); >> [/code] >> >> 这样只能在网页上显示,如何不显示这个网页,而是直接生成一个可供用户下载的文本文件,谢谢! >> >> -- >> 您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。 >> 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 >> 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。 >> 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。 >> > > -- > 您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。 > 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 > 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。 > 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。 > -- 您收到此邮件是因为您订阅了 Google 网上论坛的"PerlChina Mongers 讨论组"论坛。 要向此网上论坛发帖,请发送电子邮件至 [email protected]。 要取消订阅此网上论坛,请发送电子邮件至 [email protected]。 若有更多问题,请通过 http://groups.google.com/group/perlchina?hl=zh-CN 访问此网上论坛。
