Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
While your second two methods for creating tables are neat, i rarely need such tools. Most of my work involves getting results from a database ... the rows and columns are already determined. The only reason why i added the AoA feature was because it was too trivial to not add it. Besides, creating the table by supplying an array and some number (say, 4) is a piece of cake. ;) .o0(maybe i should add this to the CookBook)
use strict; use warnings; use DBIx::XHTML_Table; my @avengers = ( 'Iron Man', 'Black Panther', 'Thor', 'Black Widow', 'Mockingbird', 'Captain America', 'Quicksilver', 'Vision', 'Falcon', 'Scarlet Witch', 'Wasp', 'Hawkeye', 'Hercules', 'Yellowjacket', ); my $n = 4; my $rows = [map[@avengers[$_..$_+$n-1]], range(0,$#avengers,$n)]; my $headers = [map "row$_",1..$n]; print DBIx::XHTML_Table->new($rows,$headers)->output; # if Python can do this, so can Perl! sub range {grep !($_%$_[2]-$_[0]),$_[0]..$_[1]}
However, your module has this encapsulated already, so i just re-invented a wheel. ;) And i will admit that your module does one important thing that mine does not - allow the user to place the headers in a column, and not just in the top row. This is something that i plan to fix this summer. I'll use the printer terms 'landscape' and 'portrait' to describe the two different styles.

As for why my module turned up so low at search.cpan.org, well i guess it's because my module is named XHTML, not merely HTML. Shame that it doesn't get a higher hit rating ... but if you search for xhtml table, it is the first hit. Kobe, however, lists my module quite a bit higher ... html table. Thanks Randy. :)

Honestly, i see no reason why your module should not be on CPAN. I like the autogeneration feature ... maybe the name HTML::Table::Generate would be a good name for it. There really are a lot of HTML Table modules on CPAN ... i guess it's a popular problem to solve. ;)

UPDATE: changed 3 arg to range from $n - 1 to $n. My original was producing duplicate values. (chalk it up to late-nite posting) Thanks jryan. :)

UPDATE2: changed internals of range. It did not work "if the starting point is not a multiple of the increment" (quote from merlyn). Whereas the fuction works just fine for this example, it won't for other applications. The fix? Simply subtract the starting point from the result of the modulus. Better yet, just use the code i posted at emulate Python's range function.

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to (jeffa) 5Re: RFC: CGI::Tables by jeffa
in thread RFC: CGI::Tables by elusion

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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others surveying the Monastery: (3)
    As of 2019-12-07 05:05 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Strict and warnings: which comes first?



      Results (160 votes). Check out past polls.

      Notices?