while ( my $ltd = substr $string, 0, $LIMIT, '' ) { my @parts = split /\n/, $ltd; ... # do sth. with @parts, otherwise they will be sad }