1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
#!/usr/bin/env perl use strict; use warnings; open(my $tmp, '>','result_3.csv') or die $!; open(my $fh, '<', 'result_2.csv') or die $!; @ARGV = ("result_2.csv"); while(<>){ print $tmp "$_" if 2 .. eof(); } my $i = 0; my $n = 0; my $fh_out; open($fh_out, '>', "output-$n.csv") or die $!; open($tmp, '<', "result_3.csv") or die $!; while (my $line = <$tmp>) { print $fh_out $line; if ($. % 10 == 0) { close $fh_out; $n++; $i++; open($fh_out, '>', "output-$n.csv") or die $!; print $fh_out "page $i\n"; } }