Hi, thanks for your replies, did not have time to check them up to now! So it seems like I don't need to say "use feature '~~';" at all, that's o.k.

On the other hand, I find the distinction made in the current context between a literal list and an array variable having the same list as value counterintuitive and it is the first time I have tripped over such a distinction in Perl. I never thought of the last element of a list to represent in some way the value of the list, which obviously happens in the smart match context as shown in almut's last example.

I played a little more around with this and found that such a distinction is not made in case we are dealing with array references:

use feature qw / say /; sub check_match { $n++; my $expr = shift; say ("$n th match" . (eval($expr) ? ' succeeds' : ' fails')); } @a = (1, 17, 4); check_match('@a ~~ 17'); check_match('(1, 17, 4) ~~ 17'); $b = [1, 17, 4]; check_match('$b ~~ 17'); check_match('[1, 17, 4] ~~ 17');
results in the following output:
1 th match succeeds 2 th match fails 3 th match succeeds 4 th match succeeds
Now I am really puzzled, I would find it more natural if either both of cases 2 and 4 succeeded or both failed.

In reply to Re^2: Smart match operator support in Strawberry perl 5.10.0.1 (array vs. list) by jds17
in thread Smart match operator support in Strawberry perl 5.10.0.1 by jds17

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.