perl大文件读取处理的模块方法

来源:爱站网时间:2019-07-09编辑:网友分享
有时大型文件需要并行处理,但perl与其他语言不同,Perl可以使用多线程处理,实际上就是剪切文件,那么perl大文件读取处理的模块方法大家都清楚吗?下面就跟着爱站技术频道的步伐来学习吧!

有时大型文件需要并行处理,但perl与其他语言不同,Perl可以使用多线程处理,实际上就是剪切文件,那么perl大文件读取处理的模块方法大家都清楚吗?下面就跟着爱站技术频道的步伐来学习吧!

基本用法:

 

 

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

 上面就是由爱站技术频道小编为大家推荐的perl大文件读取处理的模块方法,编程学习的网站非常多,大家一定要在正规的网站上面选择适合自己的文章进行学习哦。

上一篇:perl实现简单的NIDS的方法

下一篇:perl 中文处理技巧的方法

您可能感兴趣的文章

相关阅读

查看更多 >

热门软件源码

最新软件源码下载