I have the zeal of the convert about CGI.pm, and I think you were 100% right to offer this as the solution. The various difficulties that chriso got tangled in, and which the other posters help unpick, would have been avoided altogether by using CGI.pm... that's one of the great things about it, that other, far cleverer people than I, have thought about all the problems I'm going to encounter and provided ready-to-wear solutions, so I can get on with being creative.

(Plus it's easier to read / debug by somebody else, it's quicker to type out, it's easier to cut 'n' paste into another script without disaster, you get no-brainer error-proof parameter parsing, you don't have to think about headers, you get support for CGI::Carp etc etc... in other words use CGI or die;)

Speaking as someone who used to write his CGIs out longhand on the principle that "by the time I've learnt to use CGI.pm I could have written the script from scratch" I can report with hindsight that this attitude is b*ll*cks.

I mention this in the hope of encouraging anyone who hasn't done so yet to make the jump.

My only reservation abt your solution is that you import the standard methods, but then create a CGI object - which I think means effectively importing them twice, and certainly involves extra keystrokes :). It works just the same without any OO at all:
#!/usr/bin/perl -w use CGI qw/ :standard /; use strict; my @checkbox_items = qw/one two three four five/; print header, start_html( -title => 'Checkbox group sample using CGI.pm' ), start_form; print checkbox_group( -name => 'testing', -values => \@checkbox_items, -linebreak => 1, ), submit, end_form; my @checkbox_values = param( 'testing' ); print p( 'Check a button or two and click Submit Query to see the chec +ked values.' ), li, join '<LI>', @checkbox_values; print end_html;


§ George Sherston

In reply to Re: Re: Checkbox values by George_Sherston
in thread Checkbox values by chriso

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.