I have the following arrays with different lengths

Actually, you have one array and a hash. This means you can do a simple lookup for each element of the array (i.e. $data{$element} ).

The following snippet would, for example, produce the output you want:

# ... data declarations as you have it (but with values "BCE" etc. quo +ted) print "| |", (map sprintf(" %8s |", $_), @headers), "\n"; + # print column headers print "| 1 |", (map sprintf(" %8s |", $data{$_}||""), @headers), "\n"; + # print row of data __END__ | | 2011-34 | 2011-35 | 2011-36 | 2011-37 | 2011-38 | 2011-39 +| 2011-40 | 2011-41 | | 1 | BCE | YZA | MID | KAL | | WUL +| | YOK |

P.S. please put <c> ... </c> around code sections of your post. This makes it easier to read.


In reply to Re: Need Help Mapping Arrays by Eliya
in thread Need Help Mapping Arrays by tqlam

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.