Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 将文件句柄引用为数组_Arrays_Perl_Pointers_Filehandle - Fatal编程技术网

Arrays 将文件句柄引用为数组

Arrays 将文件句柄引用为数组,arrays,perl,pointers,filehandle,Arrays,Perl,Pointers,Filehandle,考虑到我需要处理一个4GB的文件,在Perl中有没有一种方法可以像数组一样引用文件句柄,而无需将其复制到实际的数组/内存中 比如: open (LOG, "less file.txt |"); my @reference = \<LOG>; print $reference[1000000]; close LOG; open(LOG,“less file.txt |”); 我的@reference=\; 打印$reference[1000000]; 闭合日志; 谢谢 使用 嗯,不

考虑到我需要处理一个4GB的文件,在Perl中有没有一种方法可以像数组一样引用文件句柄,而无需将其复制到实际的数组/内存中

比如:

open (LOG, "less file.txt |");
my @reference = \<LOG>;
print $reference[1000000];
close LOG;
open(LOG,“less file.txt |”);
我的@reference=\;
打印$reference[1000000];
闭合日志;
谢谢

使用


嗯,不过我不需要整个文件的内容。在阅读之前,我必须对它进行grep和awk处理。那么,为什么不用Perl对它进行grep和awk处理呢?是的,我会尝试一下!谢谢大家。
use Tie::File;
tie my @array, 'Tie::File', $filename or die "tie $filename: $!";

print $array[42];