The meanings of the many of the operators in Perl 6 are quite obvious even for those who are not familiar with Perl 5. On the other hand, sometimes the behaviour of the operator contains some tiny details that you may not think of. In this chapter, we will list some operators, giving some comments when it is necessary.
The operators can be divided into a few groups depending on their syntactical properties. These groups are prefixes, infixes, postfixes, and some other types of operators that are not covered here (such as circumflex, which is the โhamburgerโ operator, like a pair of braces).
Prefix operators are those that come in front of their operands. Obviously, prefix operators require only one operand. In some cases, the symbol of the operation can be used as an infix operator when it stands between two operands.
Postfix operators are unary operators placed after their single operand.
Method prefixes. There are a few syntactical elements in Perl 6, which start with a dot. These operators might look like a postfix operator, but they all are the forms of the calling a method on an object. Unlike Perl 5, the dot operator does not do any string concatenation.
Infix operators are placed in a programme between two operands. The majority of the infix operators are binary, and there is a single ternary operator, which expects three operands.ย The simplest example of a binary operator is an addition operator +. On the right and left sides it expects two values, for example, two variables: $a + $b. It is important to understand that the same symbol or the same sequence of characters may be either an infix or a prefix operator depending on the context. In the example with a plus, the unary counterpart is a unary plus operator, which coerces the operand to a number: +$str.
Meta-operators.ย The design of the operators in Perl 6 is very consistent. For example, if you add a new operator to the language, Perl 6 will create a few more to keep the harmony. In this section, we will talk about the so-called meta-operators, the operators over other operators.
Universal comparison operators.ย There are a few operators, which can compare both strings and numbers, or even compound objects like pairs.