Hi,
I tried that, and here is my code.
use Text::Format;
my $in_string = q(It should be clear to any frequent air passenger tha
+t in order to reach one city from another, the cost of the shorter fl
+ight may be more than the cost of longer flights. In other words, it
+may pay you well to cool your heels in an airport waiting for a conne
+cting flight rather than take a more direct flight or one in which th
+e connecting time is shorter. For example, consider the following fli
+ght schedule.);
$text = Text::Format->new({
text => [$in_string],
columns => 50,
justify => 1,
firstIndent => 0,
}
);
print $text->format;
Problems from my perspective with this code:
1. I cannot say that I want this text to be spreaded in 10 lines and 90 columns. Because I like to supply the line numbers rather than calculate it.
2. The last line is not properly right-justified. It leaves all the spaces after the last word.
3. Justification should come at entire paragraph level and not just at 'line' level. So it's ok to have 2 or more spaces between the words if required, as long as entire paragraph is justfied within given 'box' of columns and lines as long as I don't see 'big' gaps between words.
Thanks,
Artist |