![]() |
|
Perl Monk, Perl Meditation | |
PerlMonks |
undef-safe equalityby hubb0r (Pilgrim) |
on Apr 21, 2005 at 19:24 UTC ( [id://450166]=perlquestion: print w/replies, xml ) | Need Help?? |
hubb0r has asked for the wisdom of the Perl Monks concerning the following question:
I've been doing a lot of database work, and I end up doing a lot of comarisons between my returned dataset and other things. The problem I'm encountering is that if I pull back a NULL value in the dataset, and do a string comparison against it, perl throws warnings about "Use of uninitialized value in string comparison" (paraphrased).
Now, I understand that these are only warnings, but I like to run with -w, and I also have a logfile that stdout and stderr are piped to, and I HATE seeing errors in it!! I thought that in one of the PERL6 snippets I've seen that there is an operator like what I am talking about, but I don't know of a clean way to do it in PERL5. I find myself writing this:
Which throws the warnings when $ret->{'val1'} is undef. So I end up going back and cluttering up my if statement like:
This makes the warnings go away, but definitely looks more cluttered and can become downright unruly depending on the if statement (and depending on which values might be undef). Anyone have any better suggestions?
Back to
Seekers of Perl Wisdom
|
|