Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I think the solution for this is going to be pretty difficult and exteremely ugly html. Let's say the first entry in @champarray has a total of 5 items. Perfect: it'll all fit in one row with 5 columns. Now, say the second entry has 7 entries. You'll fill one row and then 2 columns of the next row. That'll leave you with 3 empty columns in that second row, so in order to create valid html, you'll have to output a print td() x 3;. So yes, this would be possible, but I guarantee it'll look ugly in code, in html and visual table output. Blank cells all over just wouldn't look very appealing.

So is there no help for this? Of course there is! What I wholeheartedly propose is rather than filling columns like this, use rows. Here's some code that creates very appealing output. Code is tested, because I wasn't too sure of myself :) I really hope you consider using something based on the below code. It looks nicer, it's easy html and it's better! I changed the variable names, just because I didn't like the ones you were using :)

#!/usr/bin/perl -Tw use strict; use CGI qw/:standard *table/; my @products = ( ['Dog', 'Rover', 'Hairy', 'Smelly'], ['Cat', 'Snowball', 'Sharp', 'Smelly'], ['Mouse', 'Mousey', 'Tiny', 'Cheese'] ); print header(), start_html('Product Info'), start_table( {cellpadding=>5,border=>2,align=>'center'} ); for my $product (@products) { print Tr( th( {align=>'left'}, 'Product ID/Name:' ), td( $product->[0] ) ); my $i; for my $entry (@{$product}) { next if ++$i == @{$product}; print Tr( td( '    Entry #', $i, ':' ), td( textfield( {name=>$product->[0].$i,value=>$product->[$i],size=>25} ) ) ); } print Tr( td( {colspan=>2}, p() ) ); } print end_table(), end_html();


If the above content is missing any vital points or you feel that any of the information is misleading, incorrect or irrelevant, please feel free to downvote the post. At the same time, reply to this node or /msg me to tell me what is wrong with the post, so that I may update the node to the best of my ability. If you do not inform me as to why the post deserved a downvote, your vote does not have any significance and will be disregarded.


In reply to Re: How to iterate by fives? by Coruscate
in thread How to iterate by fives? by moof1138

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-03-28 13:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found