sub splitit { my @words = split /(\s+)/, shift; my ($left, $right) = ('', ''); while (@words) { if (length($left) < length($right)) { $left .= shift @words; } else { $right = pop(@words) . $right; } } return $left, $right; }