dryland has asked for the wisdom of the Perl Monks concerning the following question:
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: new to oop (problem with my object)
by btrott (Parson) on Nov 17, 2000 at 02:11 UTC | |
by Fastolfe (Vicar) on Nov 17, 2000 at 02:16 UTC | |
by dryland (Initiate) on Nov 17, 2000 at 02:48 UTC | |
by Fastolfe (Vicar) on Nov 17, 2000 at 02:52 UTC | |
by dryland (Initiate) on Nov 17, 2000 at 03:31 UTC | |
|
Re: new to oop (problem with my object)
by Fastolfe (Vicar) on Nov 17, 2000 at 02:06 UTC | |
by dryland (Initiate) on Nov 17, 2000 at 02:23 UTC |