my $para = ''; my $columns = $self->columns; my $cols_left = $columns; my @words = $text =~ m/(\S+)/g; while(@words) { my $w = shift @words; my $lw = length $w; if($cols_left > $lw) { if($cols_left < $columns) { $para .= ' '; $cols_left--; } $para .= $w; $cols_left -= $lw; } # etc