我有一個散列,其中包含一個大於128個字符的值,現在我通過nstore函數將該散列存儲在文件中。當散列值大於128個字符時,文件損壞perl
use strict ;
use warnings ;
use Storable qw(store nstore retrieve);
my $hash = {
###value more than 128 char
'a.key.value.in.a.hash.that.will.be.sored.in.a.file' => 'some.value.that.is.not.getting.stored.on.the.remote.server.strange.enough.if.length.is.greate.than.128.char.may.some.perl.issueee'
};
my $temp_dir = 'C:\TEMP\log';
nstore($hash, "$temp_dir/temp_file");
現在我試圖通過cgi上傳功能從本地上傳文件到遠程服務器。
通過nstore產生的本地機器上http://localhost/some/api?file=file
sub post {
my $q = new CGI;
my $filename = $q-param('file');
my $upload_filehandle = $q->upload("file");
open (UPLOADFILE, ">$upload_dir/$filename") or die "$!";
binmode UPLOADFILE;
while (<$upload_filehandle>) {
print UPLOADFILE;
}
close UPLOADFILE;
}
的問題是,如果哈希值長度大於128比remte計算機上的文件是越來越損壞,我無法以檢索回來witrh可存儲的檢索功能
我需要升級cgi嗎?我能夠直接scp文件沒有問題,但當我使用上傳功能,看到這個問題。 –
您可以嘗試使用'read()'而不是'readline()'(又名'''''';另外,'$ q-param('file')'是一個錯字。 – oals
此外,你可以給它的文件的十六進制轉儲,因爲它存儲在服務器上? * nix上的'hexdump -C yourfilehere'。 – oals