#!/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"; } }