in reply to Re: How to do tables
in thread How to do tables

This node falls below the community's minimum standard of quality and will not be displayed.

Replies are listed 'Best First'.
Re^3: How to do tables
by davorg (Chancellor) on Jan 25, 2007 at 09:46 UTC

    No, really, it is all there. You just need to know where to look.

    Ok, that's not strictly true. All that you need to know about using the Perl module is in the Perl module documentation. But the documentation assumes that you know about HTML elements and attributes (how they are used, which ones are valid in which situation, stuff like that) so it doesn't contain information about that. For that you'll need a guide to HTML.

    And even then, the documentation isn't arranged as you think it should be. There aren't sections called "all you want to know about creating tables", "all you want to know about creating lists", etc. That's for two reasons. Firstly, the way that you create element and attributes is standardised. The section on creating tables would be almost identical about the section on creating lists, so the documentation would get very repetative. Instead, there's a section on Creating Standard HTML Elements which explains the rules. You're supposed to be able to read that and extrapolate the information that you need. Secondly, if the documentation was to try and list all of the HTML elements and attributes supported by all of the browsers then it would a) be very long and b) go out of date every time a browser was updated. It's far better to have the current method which allows you to create _any_ element with _any_ attribute. That way it never goes out of date.

    So, to answer your specific questions:

    • There is no document that lists all of the attrbutes that can be given to the CGI.pm methods (or, indeed, all of the methods that can be called) as it supports any attribute on any tag. To know which elements you need and which attributes are valid on any given element then consult a good reference on HTML
    • The table method doesn't take a reference to an array that holds all the rows. It just takes a list of rows. Passing a reference to an array has a slightly different effect as the section on The Distributive Property of HTML Shortcuts demonstrates.
    • The td method creates a <td> element. The th method creates a <th> element. To get information on what these elements represent and when it's appropriate to use each one see a good HTML reference.
    • There is a book about CGI.pm. But it's been out a long while now so it's probably a bit out of date and hard to get hold of.

    Oh, and as others have pointed out, creating HTML using these CGI.pm methods can make for rather hard to maintain code. In my opinion, you'll be much better off using a decent templating system.

    Hope that makes it clearer.