最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

perl大文件讀取處理的模塊介紹

 更新時(shí)間:2013年02月08日 20:58:04   作者:  
perl CPAN中有一個(gè)Tie-File 模塊極大方便了對(duì)大文件的操作

該模塊用perl的數(shù)組代表一個(gè)文件,文件的每一行對(duì)應(yīng)數(shù)組的一個(gè)元素,第一行為元素0,第二回為1,... 
文件本身實(shí)際并不加載到內(nèi)存,對(duì)數(shù)組元素的操作立刻作用到文件里。最大的方便是可以任意指定處理開(kāi)頭結(jié)尾的某幾行。

基本用法:

復(fù)制代碼 代碼如下:

use Tie::File;
tie @array, 'Tie::File', filename or die ...;
$array[13] = 'blah'; # line 13 of the file is now 'blah'
print $array[42]; # display line 42 of the file
$n_recs = @array; # how many records are in the file?
$#array -= 2; # chop two records off the end

for (@array) {
s/PERL/Perl/g; # Replace PERL with Perl everywhere in the file
}
# These are just like regular push, pop, unshift, shift, and splice
# Except that they modify the file in the way you would expect
push @array, new recs...;
my $r1 = pop @array;
unshift @array, new recs...;
my $r2 = shift @array;
@old_recs = splice @array, 3, 7, new recs...;
untie @array; # all finished

更多功能請(qǐng)大家參考cpan上的文檔。

相關(guān)文章

最新評(píng)論

淮滨县| 凤庆县| 彰化市| 宁陕县| 镇巴县| 遂昌县| 景洪市| 肥乡县| 武乡县| 屯留县| 西乌珠穆沁旗| 镇宁| 唐海县| 清徐县| 延寿县| 罗山县| 青阳县| 安化县| 广丰县| 盐津县| 河西区| 萨迦县| 新营市| 三穗县| 昭觉县| 宜春市| 梧州市| 连城县| 旅游| 屏边| 永城市| 邵东县| 珲春市| 通州区| 通山县| 兴和县| 新蔡县| 聂拉木县| 越西县| 双城市| 东阿县|