in reply to Re^3: smart match operator should be smarter!
in thread smart match operator should be smarter!

Fixing the aforementioned bugs required making ~~ non-commutative.
  • Comment on Re^4: smart match operator should be smarter!

Replies are listed 'Best First'.
Re^5: smart match operator should be smarter!
by zwon (Abbot) on Nov 22, 2009 at 15:37 UTC

    Yup! Have tried this in 5.10.1 and now see the difference.

    use strict; use warnings; use 5.010; my @arr = (2, 5 , "aaa"); say "\@arr ~~ 5 matches" if @arr ~~ 5; say "5 ~~ \@arr matches" if 5 ~~ @arr; say "\@arr ~~ 3 matches" if @arr ~~ 3; __END__ 5 ~~ @arr matches

    But after reading "Smart matching in detail" from perlsyn I have the impression that @arr ~~ 3 expression falls under

    Any Num numeric equality $a == $b
    rule, so it should be equal to @arr == 3, and it's not, so what rule is actually applied in this case? And BTW is there any way to see what comparison have been actually performed?