I'm using CGI.pm to collect some user info through a series of web pages. I've been just writing the captured data out to a file, but now I'm trying to write to a database. For the most part this is working well, but for a few fields I'm trying to test for a value of 'blank' or 'no data' (this would be for fields left unanswered). By default perl seems to convert these to a value of 0, but I'd like to convert them to -1.
My problem is in testing for this blank value. I've tried lots of things, all of them more or less like this:
@negs = qw ( foo bar baz ); foreach $neg (@negs) { if (param('$neg') eq "") { param(-name=>"$neg", -value=>-1) ; } }
This, however, replaces *all* values of foo, bar, and baz with -1, not just the blank values.
Is there a way I can test for the blank value? Is there a better way to achieve my goal of not allowing fields to be left blank by users, but recording a value of -1 in the database for these fields?
Thanks as always,
scratch
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |