So you populate @array with an integer value pulled from the database. Then you have this snippet:
if (grep !$_ => @array) {...}
There's a good chance that this snippet has a bug. If all values are true, then there's no problem. However, what if a value is undefined? To the database, that means "I don't know what this value is." It does not mean "this value is false," so your logic may be suspect. With the latest versions of Perl, we're going to see strange things like this:
if (grep ! ($_ // 1) => @array) {...}
I think my head will melt.
If you just want to weed out empty strings and zeroes, but want to keep NULLs, do so explicitly:
grep { not defined xor length and $_ != 0 } @goo
Re:Write what you mean
Ovid on 2004-03-29T17:41:15
Yes, explicitly stating what you want is much cleaner. Still, it would be interesting to create a three-value logic mode in Perl, one where you can know that "undefined" is not false, nor is it greater or less than 13.6 (for example).