- 论坛徽章:
- 0
|
本帖最后由 浅倦 于 2015-05-07 22:06 编辑
小弟用perl写了一个cgi脚本,文件名是file.cgi,读取变量和对变量进行分割的部分在测试的时候都很正常,但第三部分打开文件并按行读入的时候,用perl file.cgi测试是正常的,但是通过浏览器测试就不读入文件。以下是源代码,希望高手能够给予解惑。
#!/usr/bin/perl -w
#print a fromatted list of all the environment variables
use strict;
print "Content-type:text/plain\n\n";
#读取变量
#my $var_top = $ENV{QUERY_STRING};
my $var_top = "Other&Rbcl";
print $var_top . "\n";
#对变量进行分割,并组成方便查询的形式
my @var_name = split /&/ , $var_top;
my $last = pop @var_name;
chomp($last);
print $last;
my $match = "";
foreach (@var_name){
$match= $match . $_ .".*";
}
chomp($match);
print $match;
my $path = "/var/www/ibi/phylogenedb/download/$last.txt";
print $path;
#在文件中查询,并输出
my $first;
my $second;
open READIN, $path or die "Cannot read $last: $!";
while (<READIN>){
print $_;
}
#open(MYFILE1,">../phylogenedb/download/sequence");
#while (chomp($first=<READIN>),chomp($second=<READIN>)){
# $_ = $first;
# if (/]$match.$last/){
# print $first . "\n" . $second . "\n";
# }
#}
close (READIN);
|
|