in reply to split file into smaller chunks

I don't think that it really matters, because your script will be limited by IO, not by CPU.

However you can get rid of a bit of duplication for example by writing the file handles to an array, something along these lines:

use strict; use warnings; use autodie qw(open); my @handles; open $handles[0], '>>', '0_999'; open $handles[1], '>>', '1000_1999'; open $handles[2], '>>', '2000_2999'; $/="//\n"; while (<>) { print { $handles[int(($. - 1)/ 1000)] } $_; }

(untested).