In your example, it's obvious that the loop condition can never be true. However, in general, determining whether a given expression is satisfiable (that is, can possibly be true) is an NP complete problem. There's no known efficient algorithm for it. You can put in more and more simple checks for more and more obvious cases, but how far down that path do you want to go?

It's also useful to be able to do something like this:

$DEBUG = 0; ... print "foo\n" if $DEBUG;
without having use warnings scream at you. So a condition that's always false is not always wrong.

Maybe you should choose variable names that don't look so similar to each other. For instance, $team1_score and $old_team1_score would be less likely to get confused than $team1_score and $team1_scorec.


In reply to Re: Should 'use warnings' check for contradictions? by no_slogan
in thread Should 'use warnings' check for contradictions? by SuperCruncher

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.