use Time::HiRes qw/ gettimeofday /; use strict; my $starttime = gettimeofday; open OUTFILE, ">file.txt" or die $!; for (1 .. 554152) { print OUTFILE "X"x100, "\n"; } close OUTFILE; print "Creating file took ", gettimeofday - $starttime, " seconds\n"; $starttime = gettimeofday; open INFILE, "file1.txt" or die $!; while () { chomp; print OUTFILE join (",", /(.{,10})/g), "\n" } print "Splitting file using regexp took ", gettimeofday - $starttime, " seconds\n"; __OUTPUT__ Creating file took 8.515625 seconds Splitting file using regexp took 1.5 seconds