Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > newbie question on output formatting/"pretty" print

Reply
Thread Tools

newbie question on output formatting/"pretty" print

 
 
martin
Guest
Posts: n/a
 
      04-17-2006
Hi, I am trying to print to a file 3 columns of information, the first
row is the label field,
consisting of 3 strings, 9, 4, and 9 characters wide. The first column
is strings, the second and third are integrs, of 1 up to 14 digits
wide.

aaaaaaaaa bbbb ccccccccc
--------------- ------- ---------------
xxxxxxxx 1 43432
xxxxxxxx 3213213 435435435
so on

I tried with printf %s and %d (- and + options also) but since the
width of second and third columns varies widely, the result is not
appealing and it needs a lot of trial and error to get something
half-decent looking. And also there seems to be no center
justificiation option with
printf.

I am wondering is there a way to get a decent print display without
too much trial and error. and juggling of fields nad printf options.
Thanks. Martin

 
Reply With Quote
 
 
 
 
A. Sinan Unur
Guest
Posts: n/a
 
      04-17-2006
"martin" <> wrote in news:1145242776.246789.46020
@z34g2000cwc.googlegroups.com:

> Hi, I am trying to print to a file 3 columns of information, the first
> row is the label field,


Have you tried:

http://search.cpan.org/~anno/Text-Ta.../Text/Table.pm

Sinan

--
A. Sinan Unur <>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc...uidelines.html

 
Reply With Quote
 
 
 
 
Ian Wilson
Guest
Posts: n/a
 
      04-18-2006
martin wrote:
> Hi, I am trying to print to a file 3 columns of information, the first
> row is the label field,
> consisting of 3 strings, 9, 4, and 9 characters wide. The first column
> is strings, the second and third are integrs, of 1 up to 14 digits
> wide.
>
> aaaaaaaaa bbbb ccccccccc
> --------------- ------- ---------------
> xxxxxxxx 1 43432
> xxxxxxxx 3213213 435435435
> so on
>
> I tried with printf %s and %d (- and + options also) but since the
> width of second and third columns varies widely, the result is not
> appealing and it needs a lot of trial and error to get something
> half-decent looking. And also there seems to be no center
> justificiation option with
> printf.
>
> I am wondering is there a way to get a decent print display without
> too much trial and error. and juggling of fields nad printf options.


I still have a soft spot for Perl's "write" function, which handles
centering and column-wrap nicely.
(see `perldoc perlform`)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
print a vs print '%s' % a vs print '%f' a David Cournapeau Python 0 12-30-2008 03:19 AM
Re: Problem - I want to print Current Output of Pdf file and shouldprint once.I get print dialog box but it is not working Lew Java 0 05-30-2007 01:31 PM
Problem - I want to print Current Output of Pdf file and should print once.I get print dialog box but it is not working keto Java 0 05-30-2007 11:27 AM
newbie question; output from simple print statement epost2@gmail.com Python 2 08-05-2005 04:23 PM
Unlarging the print to print using PDF file to print Bun Mui Computer Support 3 09-13-2004 03:15 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57