I have a parent and child class:
parent:
[CODE=perl]
#!/usr/local/bin/perl -w
#class clFormMaker
package clFormMaker;
sub new {
#constructor
my ($class_name, $name, $action, $method, $enctype) = @_;
my ($self) = {};
bless ($self, $class_name);
return $self;
}
#functions
sub makeform {
#make the form
my ($self) = @_;
print "<form name='" . $self->{'_name'} . "' action='" . $self->{'_action'} .
"' method='" . $self->{'_method'} . "' enctype='" . $self->{'_enctype'} . "'>";
}
sub closeform {
#close the form
print "</form>";
}
return(1);
[/CODE]
and a child class
child:
[CODE=perl]
#!/usr/local/bin/perl -w
#class clControlMaker
use clFormMaker;
package clFormMaker::cl ControlMaker;
#use strict;
BEGIN {@ISA = qw(clFormMaker) ;}
sub new {
#constructor
my ($class_name) = @_;
my ($self) = clFormMaker->new(@_);
#my ($self) = {};
bless ($self, $class_name);
return $self;
}
sub maketextbox {
#make a textbox with name=$name, style=$style
my ($self, $name, $style) = @_;
my $markup = "<input type='textbox' name='$name' style='$style'> <br>";
return $markup;
}
return(1);
[/CODE]
To use them I have the following code:
[CODE=perl]
use clControlMaker;
my $control = clFormMaker::cl ControlMaker->new('formname' , 'polymorphism.p l');
print $control->makeform();
print $control->maketextbox('t ester', 'width: 200px;');
print $control->maketextbox('t hename', 'width: 200px');
[/CODE]
If I just use the maketextbox method in the clControlMaker class and omit the makeform method (in the clFormMaker class) then the textboxes draw just fine. However, the problem I'm having is that every time I use one of the parent class methods (clFormMaker) a '1' is outputted to the screen. Presumably this is something to do with the return value 1 showing that the use statement worked.
How do I stop this outputting to the screen?
parent:
[CODE=perl]
#!/usr/local/bin/perl -w
#class clFormMaker
package clFormMaker;
sub new {
#constructor
my ($class_name, $name, $action, $method, $enctype) = @_;
my ($self) = {};
bless ($self, $class_name);
return $self;
}
#functions
sub makeform {
#make the form
my ($self) = @_;
print "<form name='" . $self->{'_name'} . "' action='" . $self->{'_action'} .
"' method='" . $self->{'_method'} . "' enctype='" . $self->{'_enctype'} . "'>";
}
sub closeform {
#close the form
print "</form>";
}
return(1);
[/CODE]
and a child class
child:
[CODE=perl]
#!/usr/local/bin/perl -w
#class clControlMaker
use clFormMaker;
package clFormMaker::cl ControlMaker;
#use strict;
BEGIN {@ISA = qw(clFormMaker) ;}
sub new {
#constructor
my ($class_name) = @_;
my ($self) = clFormMaker->new(@_);
#my ($self) = {};
bless ($self, $class_name);
return $self;
}
sub maketextbox {
#make a textbox with name=$name, style=$style
my ($self, $name, $style) = @_;
my $markup = "<input type='textbox' name='$name' style='$style'> <br>";
return $markup;
}
return(1);
[/CODE]
To use them I have the following code:
[CODE=perl]
use clControlMaker;
my $control = clFormMaker::cl ControlMaker->new('formname' , 'polymorphism.p l');
print $control->makeform();
print $control->maketextbox('t ester', 'width: 200px;');
print $control->maketextbox('t hename', 'width: 200px');
[/CODE]
If I just use the maketextbox method in the clControlMaker class and omit the makeform method (in the clFormMaker class) then the textboxes draw just fine. However, the problem I'm having is that every time I use one of the parent class methods (clFormMaker) a '1' is outputted to the screen. Presumably this is something to do with the return value 1 showing that the use statement worked.
How do I stop this outputting to the screen?
Comment