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 "\n"; } sub table_close { my $self = shift; if (@_) { $self->{TABLE_CLOSE} = shift } return print "
\n"; } sub row_open { my $self = shift; if (@_) { $self->{ROW_OPEN} = shift } return print "\t\n"; } sub row_close { my $self = shift; if (@_) { $self->{ROW_CLOSE} = shift } return print "\t\n"; } sub col_open { my $self = shift; if (@_) { $self->{COL_OPEN} = shift } return print "\t\t\n"; } sub col_close { my $self = shift; if (@_) { $self->{COL_CLOSE} = shift } return print "\t\t\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 "\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;