For you problem  ne compares two strings, which  /^[+-]\d+$/ is not.

Actually, the problem with the  $VAR1 ne /^[+-]?\d+$/ expression in the OPed code is much more pernicious. In the absence of a  =~ binding operator,  // matches against the  $_ default scalar. If this scalar has a defined value, there will be no warning even if warnings are enabled. The  // match occurs in scalar context imposed by the  ne comparison operator. In scalar context,  // returns 1 (true) if there is a match and '' (empty string: false) if not. The  ne operator will stringize a 1 returned from a successful match. The  ne operator will stringize  $VAR1 and compare that against whatever resulted from the  // match. If  $VAR1 is defined, there will be no warning if warnings are enabled. Most of the values one can imagine  $VAR1 to contain will not (stringwise) equal either '1' or the empty string, thus setting the stage for very puzzling behavior.

So even with strictures and warnings enabled, you might have been left with a devilish bug. Well, Perl is neither magical nor telepathic. There has to be some reason for the existence of the programmer, and that's why we earn the Big Buck$.


In reply to Re^2: if multiple conditions & Warinings.... by AnomalousMonk
in thread if multiple conditions & Warinings.... by sami.strat

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.