How do I distinguish between no value and false? I thought defined was
supposed to do that.
So if I call $q->param("xyz"), how do I distinguish between &xyz=0&abc and
&xyz=&abc and xyz being absent all together?
-----Original Message-----
From: Babale Fongo [mailto:[EMAIL PROTECTED]
Sent: Tuesday, January 04, 2005 12:48 PM
To: [email protected]
Subject: RE: How does defined work?
Both Zero "0" and empty string " " are defined values in Perl, so if you
want to test for values other than zero or empty string; then try something
like thing:
if ($nUserId) { # so "0", 0 or " " will fail here
$juror_number = $nUserId;
} else {
die "No valid ID for User";
}
||-----Original Message-----
||From: Siegfried Heintze [mailto:[EMAIL PROTECTED]
||Sent: Monday, January 03, 2005 6:58 AM
||To: [email protected]
||Subject: How does defined work?
||
||I am posting this query in beginners instead of beginners-cgi because I
||believe this is a question about the defined statement and not the
$q->param
||statement/function.
||
||I'm using this code:
||$q = new CGI;
||my $nUserId = $q->param("userId") ;
||
||I was hoping the defined keyword would tell me if userId was present, but
it
||does not seem to be doing that.
||
||How can I make this execute the die statement when userId is missing from
my
||get/post parameters?
||
|| if (defined $nUserId) {
|| $juror_number = $nUserId;
|| } else {
|| die "No valid ID for User";
|| }
||
||Thanks,
||Siegfried
||
||
||--
||To unsubscribe, e-mail: [EMAIL PROTECTED]
||For additional commands, e-mail: [EMAIL PROTECTED]
||<http://learn.perl.org/> <http://learn.perl.org/first-response>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>