現在我正在處理大文件,其大小大於(1.5 GB)。所以我用File::Map
。當輸入大於2.1 GB
腳本失敗,並顯示錯誤Use of uninitialized value $count in print at file.pl line 16.
。perl中標量變量是否有限制?
但是腳本運行2.1GB and below 2.1GB
我的腳本如下
use warnings;
use strict;
use File::Map 'map_file';
my $filename ="/root/Desktop/test_sequence/human_genome";
map_file (my $map,$filename);
my $count;
$count++ while ($map=~/>/g);
print $count; #The file has only 14 `>` so result is 14.
同時我試了一下沒有模塊。它也以相同的錯誤終止。
use warnings;
use strict;
my $filename ="/root/Desktop/test_sequence/human_genome";
open my $fh,"<",$filename or die "$!";
my $m = do{local $/; <$fh>};
my $count;
$count++ while ($m=~/>/g);
print $count;
我不知道這裏有什麼問題?
如果你正在做的是'>'計數 - 你真的需要將整個文件讀入內存? – Sobrique
@Sobrique我正試圖在文件中找到重複。所以我想計算一個文件中的標題。然後我會繼續。 – mkHun
要點是 - 你可能會找到一個'兩遍'的方法(閱讀文件尋找標記,再次讀取文件來處理它)更加高效,除非你需要做大量的數據集交叉引用。 – Sobrique