sub format { my($self, $text) = @_; my $para = ''; my $cols_left = $self->columns; my @words = $text =~ m/(\S+)/g; foreach my $w (@words) { my $lw = length $w; if($cols_left > $lw) { $para .= ' ' if $cols_left < $self->columns; $para .= $w; $cols_left -= $lw; } } return $para; }