Start with What is the difference between a list and an array? in perlfaq. It specifically shows how the wrong choice of values.
You can also start by writing down why you expected each of them to work or not to work so that we can correct your expectations. Why do you think you will get the expected results?
As for the smart match bits, there is no rule for ARRAY ~~ LIST . Predictive matching only works with pairs listed in the table in perlsyn. This will make him be one of these couples.
When you encounter these problems, try many more cases:
The conclusion of various cases is the key that you do not read correctly in the documents:
Useless use of a constant (2) in void context at test.pl line 8. Useless use of a constant (4) in void context at test.pl line 17. Useless use of a constant (5) in void context at test.pl line 17. @a is 1 2 3 @a ~~ (1,2,3) is 0 @a ~~ [1,2,3] is 1 @a ~~ 3 is 0 3 ~~ @a is 1 @b is 4 5 6 @b ~~ (4,5,6) is 0 @b ~~ [4,5,6] is 1 @b ~~ 3 is 0 3 ~~ @b is 0 @b ~~ @a is 0
source share