smrtalec <[EMAIL PROTECTED]> wrote:
: 
: #! /usr/bin/perl -w

    You should add:

use strict;

: use DBI;
: use CGI qw/:standard :html3/;
: use CGI::Carp qw(fatalsToBrowser);

    This is great for debugging. Make sure you remove it
once you go into production.


    When outputting to the browser using the Common Gateway
Interface (CGI) you need to first send a header to tell the
client (or whatever is receiving the data) what the data is.
The header is separated from the content by a single blank
line. Whenever you get a header error, check to see if you
are printing them.

    Since gen_table() is printing something, you need to
print headers before calling the sub. CGI.pm provides this
with the header() sub routine. Use it before you print
anything.

print header();

gen_table();


[snipped code - thank you]


    I like to use the same idiom as CGI.pm when possible.
All of its subroutines return text and allow me to decide
what to do with the result. IMO, gen_table() should do
the same.

print
    header(),
        start_html( 'This page has no title' ),
            gen_table( '%Ave%' ),
        end_html();


sub gen_table {
    
    my $search = shift;

    # define table heading
    my @rows    = th( [ 'id no.', 'street no.', 'street name', 'city' ] );

    # load 1 street per row
    push @rows, td( $_ ) foreach @{ query_data( $search ) };

    # produce table
    return
        table( {    -border => 0,
                    -width  => '25%' },

            caption( b( 'Wow. I can multiply!' ) ),
            Tr( [EMAIL PROTECTED] ),
        );
}


HTH,

Charles K. Clarkson
-- 
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
254 968-8328


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to