view prog/03.pl @ 1:13e80a745ef0 draft

beta2 release.
author pyon <pyon@macmini>
date Tue, 24 Aug 2021 21:30:47 +0900
parents 520044113ef0
children c0f76f8e67fa
line wrap: on
line source

# ファイル分割

my $i = 1;
for my $pdf (glob "data/*pdf") {
	open my $fi, '<', $pdf;
	binmode($fi);

	my $buf;
	my $n = sprintf "%04d", $i++;

	#---
	open my $fo3, '>', "data03/$n";
	binmode($fo3);
	read($fi, $buf, 50*1024);
	print $fo3 $buf;
	close $fo3;

	#---
	open my $fo4, '>', "data04/$n";
	binmode($fo4);
	read($fi, $buf, 100*1024);
	print $fo4 $buf;
	close $fo4;

	#---
	open my $fo8, '>', "data08/$n";
	binmode($fo8);
	while (read($fi, $buf, 1024)) {
		print $fo8 $buf;
	}
	close $fo8;

	close $fi;
}