In other words, I cannot repeat the behavior you're describing. Does the snippet you provided repeat the problem? Or is there some piece of code that we're not seeing, which is necessary for the problem to surface?
Update: I found the problem. "1" is not a valid status for a CGI.pm-created checkbox. In fact, it seems that the status expected by CGI.pm must be "ON" (case sensitive).
For example, if I run the script on its own with no command line, you get: 'value=ON checked="checked"'
If you run the script with "c1=1" on the command line, you are not passing CGI.pm what it wants to see, and instead, you get "value=ON" (without the 'checked="checked"' output).
If you run the script with "c1=ON" on the command line, you are passing CGI.pm what it wants to see, and you do get 'value=ON checked="checked"'
Perhaps CGI.pm is a little too selective by not interpreting "on" as being the same as "ON", but I don't see it as a problem for it to not consider "1" the same as "ON".
Update 2: The source for CGI.pm is a maze to me. But I did glean a few theories by looking at it. It seems that the default behavior (no command-line args) is for a checkbox to be checked. If an argument is given, it must be "ON" for that default behavior to remain. What is unclear to me after my quick review of the source is how the 'rearrange' function works (must be from CGI::Utils, inherited into CGI.pm), and if it has any bearing on the issue at all. I also don't see where "ON" must be case sensitive, but apparently it must. There are a lot of "if ($status eq $value)...." constructs that are difficult to wade through. But that does tell me one thing. Where a Regular Expression match can deal to some extent with approximation (case insensitivity, alternation, etc.), 'eq' means identical to. While I haven't dug deep enough to know for sure, it sounds like an exact criteria must be met. That's probably one reason that ON works and 'on' or '1' doesn't.
Dave
In reply to Re: Re: Re: CGI.pm quirk
by davido
in thread CGI.pm quirk
by esharris
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |