in reply to Which comparative operator should I use?

Of course the if ($cgi->param($paramname) != "") gets executed. It just has a different result than you expect. != is a numerical comparison operator, and hence, turns both it operands into numbers. "" becomes 0. $cgi->param($paramname) is very likely to be a string not starting with a number, and will hence become 0 as well. Which results in 0 != 0, which is false.

If you turn on warnings, Perl will warn you that this is happening.

Abigail

  • Comment on Re: Which comparative operator should I use?