#!/usr/bin/env perl

my $file = $ARGV[0];
my $size = $ARGV[1];
my $base = "kernel";
my $count = 0;
my $part = 1;

my $line = "";
open(FE,"<$file") or die "Can not open <$file>\n";
while(<FE>) {
	chomp();
	$line = $_;
	if($count == 0) {
		my $partname = "$base" . "_$part.csv";
		open(NW,">$partname") or die "Can not open new csv file<$partname>\n";
	}
	print NW "$line\n";
	$count += 1;
	if($count == $size) {
		close(NW);
		$count = 0;
		$part += 1;
	}
}
close(FE)
