Dear Perl experts,
I need a better way to display some information.
@names contains NameA, NameB, NameC, and NameD.
@ages contains 353, 32, 2356, and 75.
@sizes contains 44, 212, 32, and 328.
@scores contain 900, 128, 99, and 1000.
If the first element of each array go with each other, as do the second, third, and so on, is there a way to print an output like:
======================================================================
+==============
Name Age Size
+ Score
======================================================================
+==============
NameA 353 44
+ 900
NameBCG 32 212
+ 128
NameC 2356 32
+ 99
NameD 75 328
+ 1000
======================================================================
+==============
I know how to do this for the most part; it's just the alignment of values that I'm not familiar how to do ( I want to make the rightmost character in each column line up). Since the names and values may be of different lengths, I run into difficulties trying to make organized outputs like this. Is there a way to print an output in this fashion?
Thanks for any help.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.