mnlight has asked for the wisdom of the Perl Monks concerning the following question:

I cannot figure out why the radio_group() function prints out a value of 1 to my page.
Everything was working fine until I added this code now I get the radio buttons but below it I get a 1 printed to the page.
print $query->start_form('POST','/cgi-bin/Signup.pl'), print $query->radio_group( -name =>'Parent', -value =["Father", "Mother"], -linebreak=>'true', -columnheader=>'Parent'); print $query->end_form();

Edit Masem 2001-12-21 - CODE tags

Replies are listed 'Best First'.
(Ovid) Re: The value 1 prints out to the page
by Ovid (Cardinal) on Dec 22, 2001 at 02:22 UTC

    Try this:

    use strict; use CGI::Pretty; my $query = CGI::Pretty->new; print $query->start_form('POST','/cgi-bin/Signup.pl'), $query->radio_group( -name =>'Parent', -values => [ "Father", "Mother" ], -linebreak =>'true', -columnheader =>'Parent' );

    After your initial print, you have a comma. Change that to a semicolon or remove the second print statement :)

    You were getting a one (1) because you were asking Perl to print the value of the return result of the second print statement. This is almost always true.

    $ perl -e 'print "Ovid",print"Ovid"' OvidOvid1

    Cheers,
    Ovid

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Re: The value 1 prints out to the page
by grep (Monsignor) on Dec 22, 2001 at 02:23 UTC
    It looks like you missed the > on the 'value' key and there should be a semicolon on the end of
     print $query->start_form('POST','/cgi-bin/Signup.pl'),
    should be

    -value => ["Father", "Mother"],

    and print $query->start_form('POST','/cgi-bin/Signup.pl');

    grep
    grep> cd pub 
    grep> more beer
    
Re: The value 1 prints out to the page
by Chmrr (Vicar) on Dec 22, 2001 at 02:25 UTC

    You'll want that comma at the end of the first line to be a semicolon. There are a couple other typos scattered in there, too -- use strict will probably help to some extent in keeping tabs on those.

    Update: Whee! 100th post -- and, coincidentally enough, it's on my birthday, too.

    perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^`+*^e v^#$&V"+@( NO CARRIER'