Yes, that very well might return 1.  If you are getting the form
variable  data from cgi.pm then a blank form field  will appear
as an undefined value in perl, not an empty string.

So the previous posters response about testing for the true'ness of
the form value will work always and is how I usually code for this
condition now.  The why though is most likely that: undef ne ''

What I usually do if I have code that expects an empty string
instead of an undef is append an empty string onto it when I read
the cgi.pm value into it.

    $formdata{view_name} = $query->param('view_name') . '';

That way undefined form elements have a consistent value and
it's easy to just send them back out to the user if I have to
without mangling them for display.

Hope that helped some.


[EMAIL PROTECTED] wrote:

> if ( $formdata{view_name} ne "" ) {
>   $view = $formdata{view_name};
>   $viewtag = "1";
> }
>
> is there a special method for testing against a null string for a form
> field's value? i am using the above data, but it seems to always return
> with a value of "1" making me think that something is incorrect in my if
> test. the form itself does not have anything default value specified for
> view_name.
>
> finally, my questions are starting to deal with perl used within cgi. i'm
> a (brand) newbie to perl. should these questions go to beginners@ or
> cgi-list@
>
> thanks!!
> -charles

--
Perl, because 600 billion oysters can't be wrong
   Canadian Consulting Services' pet perl hacker
   David Labatte [EMAIL PROTECTED]



Reply via email to