I have to admit, I find this surprising. Looking at the perldocs for perlop, I see that:

Left Right Description and pseudocode ============================================================== += [...] Any ARRAY smartmatch each ARRAY element[3] like: grep { Any ~~ $_ } ARRAY
Ok, that's fine. So now I need to check how Any ~~ $_ works. So, a little further down, I see:
Left Right Description and pseudocode ============================================================== += [...] Any Num numeric equality like: Any == Num Num nummy[4] numeric equality like: Num == nummy undef Any check whether undefined like: !defined(Any) Any Any string equality like: Any eq Any
Now, this is interesting. When we see a number on the right, we compare with ==, even if the left doesn't look like a number. That seems wrong. I would have expected:
nummy[4] Num numeric equality like: nummy == Num
Maybe a bug report should be opened :-) (Though as I understand it, there's a fair bit of consternation about the whole smart-match thing in the first place.) I would also expect that nummy would include objects with == overridden.


In reply to Re: given-when construct unexpected bahavior wit arrays by Tanktalus
in thread given-when construct unexpected behavior with arrays by mantager

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.