top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to use CGI.pm in table in perl?

0 votes
205 views

Please help me. I can only see Hilary Duff. I can not see Taylor Momsen.
I would like to use table for that. How should I do? Here is my script.

#!/usr/bin/perl
use Modern::Perl;
use autodie;
use CGI;

my $q = CGI->new;

my %label = (
 celeb => 'Who do you fancy? : ',
 );

my %form = ( 
 celeb => $q->radio_group(-name=>'celeb',
 -values=>['Hilary Duff','Taylor Momsen'],
 -default=>'Hilary Duff'),
 submit => $q->submit,
 reset => $q->reset,
 ); 

say $q->header;
say $q->start_html;
say $q->start_form;
say $q->table(
 $q->Tr([
 $q->td([$label{celeb},$form{celeb}]),
 $q->td([$form{submit},$form{reset}]), 
 ])
 ); 
say $q->end_form;
say $q->submit;
say $q->end_form;
say $q->end_html;
posted May 18, 2013 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes
 my %form = (
       celeb => $q->radio_group(-name=>celeb,
                        -values=>[Hilary Duff,Taylor Momsen],
                        -default=>Hilary Duff),

The line above gives a warning message: Odd number of elements in hash assignment.
You can re-write that like so:

my $radio = $q->radio_group(    -name    => celeb,    -values  => [ Hilary Duff, Taylor Momsen ],     -default => Hilary Duff);
my %form = (    celeb  => $radio,    submit => $q->submit,    reset  => $q->reset,); 
answer May 18, 2013 by anonymous
Similar Questions
+1 vote

I have tried to install module PDF::FromHTML from cpan but not able to get it.
Please let me know any other module to do the same. please help

+2 votes

I try to eliminate below special character "^@" by perl in the attachment. I have tried "$.*^' regular expression for elimination in perl but fail.

Have anyone got the experience to eliminate such special character? appreciate your help.

+1 vote

I have a perl script test.pl. I want to create desktop shortcut. While I click on this shortcut icon it will run my perl script and keep the terminal open.

I have tried the command

ln -s test.pl ~/Desktop/abc

while I click on this abc Icon from my desktop. It run and same time the terminal exit. Could you please help here?

My requirement is:

I want to create desktop shortcut for particular perl program. While I click on this icon from desktop, it should run and keep the terminal open.

...