A few comments on this.

Firstly, when you're going to do a nested map like that, I don't think there's a lot of ways around using a temporary variable if you need to access $_ from both maps. If there is I'd like to know it, as I've had to do some of this recently. Perhaps someone with a more functional background can show a few cool tricks here?

Secondly, you don't want to be using local so much. You want "my" instead. You can read the reasons why at Dominus' great Coping With Scoping article.

Also, you don't need to use the double map to print your HTML. From the manual for CGI:

THE DISTRIBUTIVE PROPERTY OF HTML SHORTCUTS

One of the cool features of the HTML shortcuts is that they
are distributive.  If you give them an argument consisting of
a reference to a list, the tag will be distributed across each
element of the list.

So, instead of print table(map{Tr(map{td($_)}@$_)}@l_array) you can just use

print table( Tr([ map { td([ @$_ ]) } @a ]) );

Tony


In reply to Re: transpose AoA and HTML table AoA contents. by salvadors
in thread transpose AoA and HTML table AoA contents. by boo_radley

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.