On 5/4/07, Mathew Snyder <[EMAIL PROTECTED]> wrote:
Hello all.
Question regarding the text formatting modules out there. I've found three on
CPAN that seem to have the functionality that I'm looking for but I don't know
which would best suit my needs. The three are Text::Format, Text::Wrapper and
Text::Autoformat.
I have a script which populates and email with data that gets laid out in the
following manner:
customer_name
Ticket ID Subject hh:mm
-----------------------------------------------------------------
###### Random Ticket Subject Line ##:##
However, the subject length is not a constant. It can be quite short (maybe a
few characters long) to much longer than the alloted space I've given using
'printf'. So, I'd like to be able to do things like wrap the text at a certain
length so that it might look something like this:
customer_name
Ticket ID Subject hh:mm
-----------------------------------------------------------------
###### Random Ticket Subject Line Which Might End Up ##:##
Longer Than The Allocated Space Using printf
###### Next Random Ticket Subject Line ##:##
Of the three formatting options I've found, which might be my best bet to handle
something of this nature. Also, after deciding which is the better option, how
would I go about printing the data out? Can I populate variables with
pre-formatted text or would I perhaps do something with a printf command that
uses a call to one of the formatting methods?
snip
Take a look at Perl6::Form*. It is the replacement for the built-in
format engine of Perl 5. Your code would look something like:
print "$cust\nTicket ID Subject
hh:mm\n", '-' x 65, "\n";
for my $tkt (@tkts) {
print form
"{>>>>>>} {[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[} {>>}:{>>}",
@{$tkt}{qw/id messafe hour minute/};
}
* http://search.cpan.org/~dconway/Perl6-Form-0.04/Form.pm
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/