Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Trying to get CGI selection to print

Reply
Thread Tools

Trying to get CGI selection to print

 
 
Nene
Guest
Posts: n/a
 
      10-24-2011
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;
~

 
Reply With Quote
 
 
 
 
Steve May
Guest
Posts: n/a
 
      10-24-2011
On 10/24/2011 01:25 PM, Nene wrote:
> 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;
>


>
> sub setNodes {
> my ( $self, $nodes ) = @_;
> $self->{_nodes} = \@nodes if @nodes;
> return $self->{_nodes};
> }
>


Methinks $nodes is not the same thing as @nodes above...

\s

 
Reply With Quote
 
 
 
 
J. Gleixner
Guest
Posts: n/a
 
      10-25-2011
On 10/24/11 20:25, Nene wrote:
> 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;


When you're trying to learn something, simplify your problem by
doing one thing at a time. Remove CGI from the equation. Once
you get your program to print what you're looking for, *then* add
in the CGI parts.

> print "Content-type: text/html\n\n";

[...]

If you're going to 'use CGI qw( :standard )' you can really
simplify your code, by actually using the methods it provides.
Oh, and print can accept a list.

e.g.

print header(),
start_html(
-title => 'ESP F5 Control',
-bgcolor => 'black',
-text => '#00ffff'),
h1( 'DR F5 Control' ), "\n";

 
Reply With Quote
 
Peter J. Holzer
Guest
Posts: n/a
 
      10-26-2011
On 2011-10-24 21:13, Ben Morrow <(E-Mail Removed)> wrote:
> Quoth Nene <(E-Mail Removed)>:
>> #!/usr/bin/perl -w

>
> You want
>
> use warnings;
>
> instead of -w. warnings allows you to turn some warnings off for
> sections of your code where you need to,


This works with -w, too:

#!/usr/bin/perl -w
use strict;

my $x;

print "outside:\n";
print "-->$x<--\n";

{
no warnings 'uninitialized';
print "inside:\n";
print "-->$x<--\n";
}

print "outside again:\n";
print "-->$x<--\n";
__END__
outside:
Use of uninitialized value $x in concatenation (.) or string at ./foo line 7.
--><--
inside:
--><--
outside again:
Use of uninitialized value $x in concatenation (.) or string at ./foo line 16.
--><--


hp
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem - I want to print Current Output of Pdf file and should print once.I get print dialog box but it is not working keto Java 0 05-30-2007 11:27 AM
trying to launch a second CGI, from a parent CGI erik Perl Misc 19 06-27-2005 06:20 PM
JTable with row selection, but no cell selection Simon Niederberger Java 2 01-07-2005 04:17 PM
JS comparing innerHTML to text selection (window.getSelection() /document.selection) Andrew Crowe HTML 1 09-13-2004 02:22 PM
HOWTO autopost the selection list upon selection curiousity ASP .Net Mobile 0 11-21-2003 12:57 AM



Advertisments