Yes, you can "turn off some warnings" as you ask in your first sentence, but it appears that you really want your nix box to issue one. Why it fails to do so, I can't say, but the same behavior occurs with AS Perl 5.014 sub 2 on a Win 7 box.

That seems odd, since the single equals sign is an assignment; the message you cite correctly suggests using == in the conditional. The rest is merely an expansion on dasgar's observation:

FWIW, with alternate code,

my @count = qw/1 2 3 4/; while ( my ( $iter, $value ) = each @count ){ if ($value < 2 ) { print "$iter: one\n"; } elsif ($value == 2) { # NO ERROR HERE, NOW say "$iter: HA!\n"; } else { print "$iter: three!\n"; } }

one receives the expected values,

0: one 1: HA! 2: three! 3: three! # This is a very special case where 4 == three :-)

and restoring the single equals sign in the conditional

my @count = qw/1 2 3 4/; while ( my ( $iter, $value ) = each @count ){ if ($value < 2 ) { print "$iter: one\n"; } elsif ($value = 2) { # LOGICAL ERROR HERE # assignment rather than test of equality # but no 'plaints from Perl print "$iter: HA!\n"; } else { print "$iter: three!\n"; } }

... also produces the expected (but incorrect, if I understand you correctly) sequence of output,

0: one 1: HA! 2: HA! 3: HA!

I can only guess the Perl version on your Mac is slightly better at noting the problem.

Update: Corrected typos and bad markup... but also noted that you say the Mac version cites an error at line 36. It's line 21 in the code you posted... and even allowing for a hashbang and a blank line, that doesn't match well with "36." Is there something else in the code on either machine that you didn't show us that might explain the mystery?


In reply to Re: Failing to warn about "Found = in conditional" by ww
in thread Failing to warn about "Found = in conditional" by Ineffectual

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.