I have this bit of opening code for a CGI script--actually, I have it in many scripts.
#!/usr/bin/perl -w use strict; use CGI qw/:standard/; my $q = new CGI; my $choice = param('choice') || 1;
This works just fine until recently when I tried to pass a parameter value of 0 (i.e., script.cgi?choice=0). If I give it zero within quotes (i.e., script.cgi?choice='0'), it works. Otherwise, the value reverts to the default of 1.
It seems to be thinking that 0 is nothing. Is there any way that I can tell it to accept 0 through the web browser and to only use the || value when results are null? Or do I have to reverse my script after this parameter and make the default 0? Another possibility would be to put the value in quotes when sending it from the previous script. I guess that would be easy enough. I'm just wondering if there's a notation to param() that I could use instead.
-Spenser
That's Spenser, with an "s" like the detective.
In reply to param = 0, not NULL by Spenser
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |