N
Nene
I'm still in the process of learning Perl CGI and OOP for Perl.
I'm trying get what I selected to print to screen but It doesn't. I
want to print $object->getNodes(), br;
#!/usr/bin/perl -w
use strict;
use CGI ':standard';
use Practice;
use Data:umper;
my $status;
print "Content-type: text/html\n\n";
print start_html(-title=>'ESP F5 Control',
-bgcolor=>'black',
-text=>'#00FFFF');
print "<h1>DR F5 Control</h1>\n";
print_prompt();
do_work();
print end_html;
sub print_prompt {
print start_form;
print "\n", br;
print popup_menu(
-name=>'Env',
-values=>['abc','cde','efg'],
-linebreak=>'yes');
print "<p><em>Servers</em><br>",
checkbox_group(
-name=>'sequence',
-default=>'',
-linebreak=>'true',
-values=>['10.254.22.66',
'10.254.22.67',
'10.254.22.68',
'10.254.22.69',
'10.254.22.70',
'10.254.22.71',
'10.254.22.72',
'10.254.22.73'],
-labels=>\my %labels,
-attributes=>\my %attributes);
print "<p><em>What action to execute?</em> ";
print "\n", br;
print radio_group(-name=>'status',
-
values=>['enabled','disabled']);
print "\n\n", br;
print "\n", br submit('Action','Submit');
print "\n\n", br;
print endform;
print "<hr>\n";
}
my @n;
sub do_work {
##################################
##################################
my(@values,$key);
print "<h2>Here are the current settings in this
form</h2>";
@values = param('sequence');
chomp(@values);
for my $value (@values) {
my $line = "$value:a";
push(@n, "$line");
}
#####################################
}
my $object = new Practice();
$object->setNodes(@n);
print $object->getNodes(), br;
#####
package Practice;
sub new
{
my $class = shift;
my $self = {};
bless $self, $class;
return $self;
}
sub setEsp {
my ( $self, @esp ) = @_;
$self->{_esp} = \@esp if @esp;
return $self->{_esp};
}
sub getEsp {
my( $self ) = @_;
return @{ $self->{_esp} };
}
sub setStatus {
my ( $self, $status ) = @_;
$self->{_status} = \$status if $status;
return $self->{_status};
}
sub getStatus {
my( $self ) = @_;
return @{ $self->{_status} };
}
sub setNodes {
my ( $self, $nodes ) = @_;
$self->{_nodes} = \@nodes if @nodes;
return $self->{_nodes};
}
sub getNodes {
my( $self ) = @_;
return @{ $self->{_nodes} };
}
1;
~
I'm trying get what I selected to print to screen but It doesn't. I
want to print $object->getNodes(), br;
#!/usr/bin/perl -w
use strict;
use CGI ':standard';
use Practice;
use Data:umper;
my $status;
print "Content-type: text/html\n\n";
print start_html(-title=>'ESP F5 Control',
-bgcolor=>'black',
-text=>'#00FFFF');
print "<h1>DR F5 Control</h1>\n";
print_prompt();
do_work();
print end_html;
sub print_prompt {
print start_form;
print "\n", br;
print popup_menu(
-name=>'Env',
-values=>['abc','cde','efg'],
-linebreak=>'yes');
print "<p><em>Servers</em><br>",
checkbox_group(
-name=>'sequence',
-default=>'',
-linebreak=>'true',
-values=>['10.254.22.66',
'10.254.22.67',
'10.254.22.68',
'10.254.22.69',
'10.254.22.70',
'10.254.22.71',
'10.254.22.72',
'10.254.22.73'],
-labels=>\my %labels,
-attributes=>\my %attributes);
print "<p><em>What action to execute?</em> ";
print "\n", br;
print radio_group(-name=>'status',
-
values=>['enabled','disabled']);
print "\n\n", br;
print "\n", br submit('Action','Submit');
print "\n\n", br;
print endform;
print "<hr>\n";
}
my @n;
sub do_work {
##################################
##################################
my(@values,$key);
print "<h2>Here are the current settings in this
form</h2>";
@values = param('sequence');
chomp(@values);
for my $value (@values) {
my $line = "$value:a";
push(@n, "$line");
}
#####################################
}
my $object = new Practice();
$object->setNodes(@n);
print $object->getNodes(), br;
#####
package Practice;
sub new
{
my $class = shift;
my $self = {};
bless $self, $class;
return $self;
}
sub setEsp {
my ( $self, @esp ) = @_;
$self->{_esp} = \@esp if @esp;
return $self->{_esp};
}
sub getEsp {
my( $self ) = @_;
return @{ $self->{_esp} };
}
sub setStatus {
my ( $self, $status ) = @_;
$self->{_status} = \$status if $status;
return $self->{_status};
}
sub getStatus {
my( $self ) = @_;
return @{ $self->{_status} };
}
sub setNodes {
my ( $self, $nodes ) = @_;
$self->{_nodes} = \@nodes if @nodes;
return $self->{_nodes};
}
sub getNodes {
my( $self ) = @_;
return @{ $self->{_nodes} };
}
1;
~