Undefined subroutine CGI::radio

2019-08-03 18:46发布

问题:

I have an application about a student data,and i am trying to make a radio-group which has options about gender of the student. But it shows me the following error: Undefined subroutine CGI::radio at C:/wamp/bin/apache/apache2.2.22/cgi-bin/modify.pl line 196

   $cInput .= $q->div({-class => 'control-group'},
                    $q->label({-class => 'control-label', -for => 'gender'}, "Gender:"), 
                    $q->div({class => 'controls'}, 
                    $q->span({class => 'span12'},
                    $q->label({-class => 'blue'},
                    $q->radio-group({-id => 'gender', -name => 'gender', -values => ['M','F'],-labels => \%labels, -default => $cGender, 'true'})))));  

What may be the problem?

回答1:

You are trying to call $q->radio-group but:

  1. The - is being treated as a subtraction operator
  2. The method is called radio_group (with an underscore)

See the documentation



标签: perl cgi