Hello Monks.
Right here is the problem
I have a data structure as follows:
%HoH = (
flintstones => {
lead => "fred",
pal => "barney",
},
jetsons => {
lead => "george",
wife => "jane",
"his boy" => "elroy",
},
simpsons => {
lead => "homer",
wife => "marge",
kid => "bart",
},
);
Now, I wish to generate a
TEXT table looking like this:
flintstones jetsons simpsons
------------- --------------- -----------
lead, fred lead , george lead, homer
pal , barney wife , jane wife, marge
his boy, elroy kid , bart
Ideal place to use formats? You bet. BUT....
I cannot create a format as follows:
format LINE=
@<<<<<,@<<<<<< @<<<<<,@<<<<<<<< @<<<<<,@<<<<<<<<
$role1,$name1 $role2,$name2 $role3,$name3
.
because, I don't know who many "flintstones, jetsons, simpsons, etc. there will be at the time I create the program.
So, I would like to create a format like this:
format LINE=
@<<<<<,@<<<<<<
$role ,$name
.
Then, when I write the record, I can write the format all on one line over and over while I still have cartoon characters in the HoH.
The effect will be a table in text format.
So there it is.
I know there is the
$: operator which gets a brief mention in the perlform docs, and Randall Schwartz mentions some stuff with formats in Learning Perl, but I need something a little more complex.
Thanks monks
Hambo
Open Source - Where everything is QED
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.