Assignment Operators
[% a = b # regular assignment a => b # fat comma quotes LHS: ('a', b) foo( a = 10, b = 20 ) # foo({ a => 10, b => 20 }) foo( a => 10, b => 20 ) # foo( a => 10, b => 20 ) # foo('a', 10, 'b', 20) foo({ a => 10, b => 20 }) # foo({ a => 10, b => 20 }) %]--EOF--look inside...
Thus Spake Andy:
The assignment operator is the same as in TT2 and does exactly what you
expect. In TT2 the =>
fat comma was an alias for =
. In TT3 it works
just like Perl in simply quoting the bareword on the left. When calling
a function/method with named parameters, TT3 will continue to do it's
magical thing when you use =
(magical being collecting up all named params
and passing them as a single hash reference). However, if your function/method
isn't expecting that then you can use =>
just as you would in Perl. You
can also explicitly use { ... }
to create a hash reference if you prefer.
So the general rule is that if you do it the same way you would in Perl (using
=>
) then it does the same thing that Perl does. If you use =
then you
get TT magic.