我有下面的PERL腳本試圖下載包含該腳本輸出的文件。通過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;
我已經調整了我的腳本如下。由於我是PERL的新手,我不瞭解文檔安全概念。 open(DOWNLOADFILE,「<$ out_file」)或死「$!」; print $ q-> header( -type =>'application/octet-stream' -attachment =>「$ out_file」); 關閉DOWNLOADFILE; 這次腳本運行成功,但out_file不可用於下載。請你幫我解決這個問題。 – Vijay