The
->
operator is perl's method of de-referencing an object reference. It is used to access an objects methods or properties (methods are the code associated with an object, and its properties are its data). So
$ans->cmp;Means the call the
cup
method of the $ans
object, and $ans->{test_points}
means the data stored as test_points
for $ans
. I don't know a good word to replace ->
, but you can think of it as a possessive, so the first example can be read "$ans
's cmp
", and the second as "$ans
's test_points
".
The use of ->
does not depend on the context. It is part of perl itself, not MathObejcts. But because MathObjects are instances of perl Objects, you do use ->
with them.