谢谢,已解决 On May 7, 3:27 am, 宇捷 <[email protected]> wrote: > Header设置两个属性: > 格式:"Content-type: application/xxx"可以是 > force-download,file,zip,octet-stream等等 > 文件名:"Content-Disposition: attachment; filename=xxx" filename记得正确编 > 码,另外IE里有一个特定bug,不会遇到就算了。。 > > -----邮件原件----- > 发件人: [email protected] > [mailto:[email protected]] 代表 > camelbbs > 发送时间: 2010年5月7日 6:55 > 收件人: PerlChina Mongers 讨论组 > 主题: [PerlChina] 请问一个perl CGI输出文本的简单程序 > > 我有一个小程序,需要用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 访问此网上论坛。
