我有下面的 PERL 脚本,它尝试下载包含该脚本输出的文件。
我面临一个错误,上面写着:
无法在 C:/Apache24/cgi-bin/trim.pl 的未定义值上调用方法“标题”
但是,我的输出文件会在正确的目的地正确写入。请帮助我修复代码并下载输出文件。
use strict;
use CGI;
use CGI::Carp qw ( fatalsToBrowser );
use File::Basename;
my $q = new CGI;
my $upload_dir = "C:/Apache24/htdocs/files" ;
my ($bytesread, $buffer);
my $numbytes = 1024;
my $trim_out_dir = "C:/Users/Admin/Desktop/vijay/Metagenomics/NGSQCToolkit_v2.3/CGI_Out";
my $out_file = "$trim_out_dir/trimmed.fasta";
my $safe_filename_characters = "a-zA-Z0-9_.-";
$q->cgi_error and error( $q, "Error transferring file: " . $q->cgi_error );
my $file = $q->param( "seq" ) || error( $q, "No file received." );
my $length = $q->param( "len");
my $quality = $q->param( "qual");
open ( UPLOADFILE, ">$upload_dir/$file" ) or die "$!";
while ($bytesread = read($file, $buffer, $numbytes)) {
print UPLOADFILE $buffer;
}
close UPLOADFILE;
system("Reads.pl -i $upload_dir/$file -n $length -o $out_file");
open ( DOWNLOADFILE, "<$out_file" ) or die "$!";
print $cgi->header(
-type => 'application/octet-stream'
-attachment => '$out_file');
close DOWNLOADFILE;