返回顶部

收藏

分割合并文件

更多
use strict;
my $ItemSize = 1024 * 1024 * 100;
open(FILEHANDLE, "< a1.mkv");
binmode   FILEHANDLE;
seek(FILEHANDLE,0,2);
print "file size is " . tell(FILEHANDLE) . "\n" ;
my $fileNum = tell(FILEHANDLE) / $ItemSize;
seek(FILEHANDLE,0,0);
print "file pos is " . tell(FILEHANDLE) . "\n" ;
# my $len = read(FILEHANDLE,my $FileCon, 12);
# print $len;
for(my $i = 0; $i <$fileNum; $i++) {
 my $FileCon;
 open(TEMPFILEHANDLE, "+>", "$i" . "\.DATA");
 binmode TEMPFILEHANDLE;
 my $ContRead = read(FILEHANDLE, $FileCon,$ItemSize);
 print $ContRead . "\n";
 print "file pos is " . tell(FILEHANDLE) . "\n" ;
 print TEMPFILEHANDLE $FileCon;
 if ( $ContRead < $ItemSize) {
  $ContRead = read(FILEHANDLE, $FileCon, $ItemSize -  $ContRead);
  print $ContRead . "\n";
  print TEMPFILEHANDLE $FileCon;
 }

 close(TEMPFILEHANDLE);
}

close(FILEHANDLE);

标签:perl

收藏

0人收藏

支持

0

反对

0