foreach my $w (@words) { my $lw = length $w; if($cols_left > $lw) { if($cols_left < $self->columns) { $para .= ' '; $cols_left--; } $para .= $w; $cols_left -= $lw; } else { # ...