use strict; use warnings; die "Usage $0 from to" unless @ARGV == 2; my $to = pop @ARGV; $to .= ".%03d"; my $count = 1; my $fh; while (<>) { if ($. % 4000 == 1) { unless ($. == 1) { close $fh or die; } open $fh, ">", sprintf $to, $count ++ or die; } print $fh $_; } close $fh or die;
In reply to Re: Split files into chunks of $n lines
by Anonymous Monk
in thread Split files into chunks of $n lines
by ktsirig
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |