I've been working on a script using CGI.pm for which I need the 'nosticky' option. That is:
-nosticky By default the CGI module implements a state-preserving behavior called "sticky" fields. The way this works is that if you are regenerating a form, the methods that generate the form field values will interrogate param() to see if similarly-named parameters are present in the query string. If they find a like-named parameter, they will use it to set their default values. Sometimes this isn't what you want. The -nosticky pragma prevents this behavior. You can also selectively change the sticky behavior in each element that you generate.
I've seen a number of posts here and elsewhere complaining about it, and after a few hours of frustration I finally decided to dig through the code to figure out what was going wrong. As far as I can tell, the nosticky option does almost nothing. It's only referenced by the submit method, and has no effect even there if you supply a label for the submit button. The override option, on the other hand, does work. Unfortunately, you have to pass it to every output method instead of setting it globally. I wrote up a small test script to demonstrate the problem, and I've hosted a copy here
#!/usr/bin/env perl use strict; use warnings; use CGI qw/-nosticky :standard/; print header, html( start_form, checkbox( -nosticky => 1, -name => "checkbox", -label => "Broken (using nosticky)", -checked => 0 ), br, checkbox( -override => 1, -name => "checkbox", -label => "Working (using override)", -checked => 0 ), br, submit, end_form );
If you check both boxes and click Submit, the second one will correctly be cleared, but the first one will stay checked. It seems really odd that a feature that's been around for so long in such a prominent module could have been broken all this time, so I still feel like I must be doing something wrong, but I can't see what it would be.

In reply to CGI.pm nosticky option does not work by robobunny

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.