Hello.. I thought I would try to write a generic table object but i'm running into problems.. no error codes are being sent back and i'm to new to oop in perl to know what I'm doing wrong, any help would be greatly appreciated..(any suggestions for improvement would be welcome too) below is my attempt at the code:
package Table; # Generic HTML Table Object #define class sub new { my $proto = shift; my $class = ref($proto) || $proto; my $self = {}; $self->{TABLE_OPEN} = undef; $self->{TABLE_CLOSE} = undef; $self->{ROW_OPEN} = undef; $self->{ROW_CLOSE} = undef; $self->{COL_OPEN} = undef; $self->{COL_CLOSE} = undef; $self->{NAME} = undef; $self->{VALUE} = undef; bless ($self, $class); return $self; } ################################################# # begin table methods sub table_open { my $self = shift; if (@_) { $self->{TABLE_OPEN} = shift } return print "<table>\n"; } sub table_close { my $self = shift; if (@_) { $self->{TABLE_CLOSE} = shift } return print "</table>\n"; } sub row_open { my $self = shift; if (@_) { $self->{ROW_OPEN} = shift } return print "\t<tr>\n"; } sub row_close { my $self = shift; if (@_) { $self->{ROW_CLOSE} = shift } return print "\t</tr>\n"; } sub col_open { my $self = shift; if (@_) { $self->{COL_OPEN} = shift } return print "\t\t<td>\n"; } sub col_close { my $self = shift; if (@_) { $self->{COL_CLOSE} = shift } return print "\t\t</td>\n"; } sub name { my $self = shift; if (@_) { $self->{NAME} = shift } return $self->{NAME}; } sub value { my $self = shift; if (@_) { $self->{VALUE} = shift } return $self->{VALUE}; } 1; ################################################ # begin script that i'm using to test the object #!/usr/bin/perl require 5; use Web; # my web processing module use Table; $website = ''; &parse(); # parse html post/get using the Web module &check_referer($website); # check refering url using the Web module &check_required('test'); # check required fields using the Web module print "Content-type:text/html\n\n"; print "<html><body>\n"; print "test = " . $in{'test'} . "\n"; my($table) = new Table(); $table->open_table; foreach $i (sort keys %in){ $table->open_row; $table->open_col; $table->name($i); $table->name; $table->close_col; $table->open_col; $table->value($in{$i}); $table->value; $table->close_col; $table->close_row; } $table->close_table; print "got here\n"; exit;

In reply to new to oop (problem with my object) by dryland

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.