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

Hi, I am a new Perl fan from China, during the study, I found that there is difference between the Web Server of my company and the ones of others. If I use it like: @arry=<stdin>;print @arry; Then I will see a special file, like the following:
<form method="POST" action="mycgi.pl"> Your name:<input type="text" name="T1" size="20"> Your sex:<input type="radio" value="V1" checked name="R1"> <input type="radio" name="R1" value="V2"> What color you like:<input type="checkbox" name="C1" value="red">red <input type="checkbox" name="C2" value="green">green <input type="checkbox" name="C3" value="blue">blue What sport you like :<select name="D1" multiple size="1"> <option value="football">football</option> <option value="basketball">basketball</option> <option value="running">running</option> </select> tell me others:<textarea rows="2" name="S1" cols="20"> </textarea> <input type="submit"><input type="reset"> </form>
When I apply such form, and view the code of the webpage, it will appear as
<NAME> T1 zhang <NAME> R1 V1 <NAME> C1 red <NAME> C2 green <NAEM> D1 football <NAME> D1 basketball <NAME> S1 i love you! <NAEM> S1 i love this game!
How can I use a fixed module to make the names and the values of the variables 1 to 1, like:
C1=red;D1=(football,basketball);S1=(i love you!,i love this game)
Thanks a lot in advance

Replies are listed 'Best First'.
(kudra: CGI.pm) Re: a Perl question
by kudra (Vicar) on Aug 29, 2000 at 14:46 UTC
    Try using CGI.pm to retrieve your form values. Here's an example.
Re: a Perl question
by Jouke (Curate) on Aug 29, 2000 at 15:25 UTC
    When you use CGI.pm, beware that if you use multiple checkboxes with the same name (like you do in your example), you will have to split the resulting scalar on the "\0".
    If you only checked one of them, you can safely use the result as a scalar, but if multiple boxes are checked, you can get the seperate values by splitting them...

    Update Of course -as always- merlyn is right. I'm totally wrong here... :( HTH,

    Jouke Visser, Perl 'Adept'
      You seem to have CGI.pm and that old decrepit cgi-lib.pl confused.

      CGI.pm is just fine with multiple checkboxes:

      @selections = param("state");
      In a scalar context, param returns the first selection it sees. In a list context, it returns the entire list of selections. At no time does anything come back with a NUL separator.

      -- Randal L. Schwartz, Perl hacker

        I'm begging for your absolution :-|

        Jouke Visser, Perl 'Adept'