N
Nene
I’m learning PERL CGI with OOP.
Below is my code for the user to select the number of servers.
print "<p><em>Servers</em><br>",
checkbox_group(
-name=>'sequence',
-default=>'',
-linebreak=>'true',
-values=>['10.233.22.66',
'10.233.22.67',
'10.233.22.68',
'10.233.22.69',
'10.233.22.70',
'10.233.22.71',
'10.233.22.72',
'10.233.22.73'],
-labels=>\my %labels,
-attributes=>\my %attributes);
###This is how process the selection of servers.
@values = param('sequence');
chomp(@values);
foreach my $line (@values) {
my $line =~ s/$_/$line:a/;
push(@n, "$line");
}
Here’s my OOP code that is in the same file.
my $object = new Misc();
my @e = $object->setNodes(@n);
my @c = $object->getNodes();
print "\n", br;
#######################################
print @c, br;
#######################################
But it’s not printing at all.
#######################################
Below is my package:
package Misc;
sub new
{
my $class = shift;
my $self = {};
bless $self, $class;
return $self;
}
sub setPse {
my ( $self, @pse ) = @_;
$self->{_pse} = @pse if defined(@pse);
return $self->{_pse};
}
sub getPse {
my( $self ) = @_;
return $self->{_pse};
}
sub setStatus {
my ( $self, $status ) = @_;
$self->{_status} = $status if defined($pse);
return $self->{_status};
}
sub getStatus {
my( $self ) = @_;
return $self->{_status};
}
sub setNodes {
my ( $self, $nodes ) = @_;
$self->{_nodes} = $pse if defined($nodes);
return $self->{_nodes};
}
sub getNodes {
my( $self ) = @_;
return $self->{_nodes};
}
1;
Below is my code for the user to select the number of servers.
print "<p><em>Servers</em><br>",
checkbox_group(
-name=>'sequence',
-default=>'',
-linebreak=>'true',
-values=>['10.233.22.66',
'10.233.22.67',
'10.233.22.68',
'10.233.22.69',
'10.233.22.70',
'10.233.22.71',
'10.233.22.72',
'10.233.22.73'],
-labels=>\my %labels,
-attributes=>\my %attributes);
###This is how process the selection of servers.
@values = param('sequence');
chomp(@values);
foreach my $line (@values) {
my $line =~ s/$_/$line:a/;
push(@n, "$line");
}
Here’s my OOP code that is in the same file.
my $object = new Misc();
my @e = $object->setNodes(@n);
my @c = $object->getNodes();
print "\n", br;
#######################################
print @c, br;
#######################################
But it’s not printing at all.
#######################################
Below is my package:
package Misc;
sub new
{
my $class = shift;
my $self = {};
bless $self, $class;
return $self;
}
sub setPse {
my ( $self, @pse ) = @_;
$self->{_pse} = @pse if defined(@pse);
return $self->{_pse};
}
sub getPse {
my( $self ) = @_;
return $self->{_pse};
}
sub setStatus {
my ( $self, $status ) = @_;
$self->{_status} = $status if defined($pse);
return $self->{_status};
}
sub getStatus {
my( $self ) = @_;
return $self->{_status};
}
sub setNodes {
my ( $self, $nodes ) = @_;
$self->{_nodes} = $pse if defined($nodes);
return $self->{_nodes};
}
sub getNodes {
my( $self ) = @_;
return $self->{_nodes};
}
1;