September 2017
Beginner
402 pages
9h 52m
English
The ==> and <== operators pass the values similarly to how the | pipe operator passes data in the Unix command-line shells.
Consider the following example:
my @a = (10...0 ==> grep {$_ > 5} ==> sort);say @a;
Here, the @a array is created in three steps. , the sequence from 10 to 0 is generated with the ... operator, then the values are passed to the grep function that selects numbers of more than five. After that, the values go to the sort method.
The result of this program is a sorted list of integers between 6 and 10:
[6 7 8 9 10]
The <== operator organizes data flow in the opposite direction:
my @b = (sort() <== grep {$_ > 5} <== 10...0);say @b; # [6 7 8 9 10]
Notice that, in this case, parentheses after the sort call ...