将磁盘上文件的指定字节范围提取到变量中的最方便方法是什么?
最佳答案
seek
到范围的开头, read
所需的字节数(或 sysseek
/sysread
-- 请参阅 nohat 的评论)。
open $fh, '<', $filename;
seek $fh, $startByte, 0;
$numRead = read $fh, $buffer, $endByte - $startByte; # + 1
&do_something_with($buffer);
关于perl - 如何使用 Perl 访问文件中特定范围的字节?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2655536/