It seems to me that if a statement is wrong, it should not evaluate to true, what am I missing here?
What's your definition of wrong? I can think of at least three:
- Your syntax is incorrect. In that case, it won't compile, it won't run, and it certainly doesn't evaluate to true.
- You do something Perl cannot do, or has been forbidden to do. Dividing by zero for instance, or dereferencing a string while "use strict 'refs'" is active. In that case, Perl will throw an exception - it will not continue with false (besides, what should be false? A term of the expression? The expression? The block? The current subroutine?). Although one may say that if the exception isn't dealt with, Perl evaluates the entire program to false. ;-)
- You used the wrong (business) logic. How's Perl supposed to know? You might as well ask Gravity to not shatter the priceless vase if you dropped it by accident instead of intentionally.
In your case, you used the wrong logic. Perl is kindly enough to warn you "are you sure you want this?", but it has no grounds to declare anything wrong, so it just shoulders on bravely.