in reply to Re^2: ~~ and list literal
in thread ~~ and list literal
Why does "x" ~~ "a", "b", "c" always give 1?
It doesn't; it evaluates to "c".
"," is a very low precedence operator. "x" ~~ "a", "b", "c" means ("x" ~~ "a"), "b", "c", which evaluates to "c" in scalar context.
And why does "x" ~~ sub { "a", "b", "c" } also give 1?
It doesn't; it evaluates to "c".
"x" ~~ sub { "a", "b", "c" } is the same as scalar( sub { "a", "b", "c" }->($x) ). Since "a", "b", "c" evaluates to "c" in scalar context, that is what is returned.
|
---|
In Section
Seekers of Perl Wisdom