for my $temp ($str =~ /.{1,1000}/g) { # do stuff with $temp }