if (length($html[$i]) > 1000000) ## $html[$i] holds the current string of html { my @bigHTML = ### Split here #########; for (my $z=0; $z <= $#bigHTML; $z++) { open (my $file, '>', "giant_${i}_$z.htm") or die $!; print $file $bigHTML[$z]; close $file; push(@lists, "giant_${i}_$z.htm"); } } else { ### Proceed normally