use warnings; use strict; #### use warnings; use strict; $count = 0; open (DISTLISTS, " < rdy.csv") || die "Unable host file for splitting: $!."; while () { chomp $dist_split; if ($. % 200 == 0) { # modular arithmetic $count ++; } my $filename = "file$count.csv"; open (OUTPUT1, " >>$filename") print OUTPUT1 "$dist_split\n"; close OUTPUT1; }