I have a parent and child class:
parent:
-
#!/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);
-
and a child class
child:
-
#!/usr/local/bin/perl -w
-
#class clControlMaker
-
-
use clFormMaker;
-
package clFormMaker::clControlMaker;
-
-
#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);
-
To use them I have the following code:
-
use clControlMaker;
-
my $control = clFormMaker::clControlMaker->new('formname', 'polymorphism.pl');
-
print $control->makeform();
-
print $control->maketextbox('tester', 'width: 200px;');
-
print $control->maketextbox('thename', 'width: 200px');
-
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?