While poking around my thoughts about this node (Strange "Useless use of constant" message: should not appear at all!), I came across the fact that the warning messages seem to ignore '0's and '1's.

Example: (please ignore the fact that this code doesn't really do anything, it's meant to illustrate the warning messages only)

#!/usr/bin/perl -w use strict; # Why the inconsistency with warning messages? my @movement = (0,1,2,3,4); my $from = ""; if (@movement == (0,1,2)) {$from = "012"} # no warning if (@movement == (1,2,3)) {$from = "123"} # 1 warning if (@movement == (2,3,4)) {$from = "234"} # 2 warnings if (@movement == (3,4,5)) {$from = "345"} # 2 warnings if (@movement == (-0,-1,-2)) {$from = "012"} # 1 warning if (@movement == (-1,-2,-3)) {$from = "123"} # 2 warnings if (@movement == (-2,-3,-4)) {$from = "234"} # 2 warnings if (@movement == (-3,-4,-5)) {$from = "345"} # 2 warnings if (@movement == (0,1,0,1)) {$from = "0101"} # no warning if (@movement == (1,2,1,2)) {$from = "1212"} # 1 warning if (@movement == (2,3,2,3)) {$from = "2323"} # 3 warnings if (@movement == (3,4,3,4)) {$from = "3434"} # 3 warnings
Does anyone know why there are different numbers of warnings? (We expect one warning per number that gets thrown away within the list)
(i.e. it doesn't give warnings for any of the numbers in the list that it throws away if that number is a zero or one).

Does this affect anything that I do in my daily coding life? Not likely, I just wanna know 'cause I'm curious.

Sandy

UPDATE

Thanks to all the posters below. It's these little details that make learning stuff all the more interesting.


In reply to Warning messages about useless constants ignore '0's and '1's by Sandy

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.