Skip to Content
Perl 6 Deep Dive
book

Perl 6 Deep Dive

by Andrew Shitov
September 2017
Beginner
402 pages
9h 52m
English
Packt Publishing
Content preview from Perl 6 Deep Dive

Data pipe operators

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Perl Hacks

Perl Hacks

Chromatic, Damian Conway, Curtis Ovid Poe, Curtis (Ovid) Poe
Learning Perl 6

Learning Perl 6

brian d foy
Think Perl 6

Think Perl 6

Laurent Rosenfeld, Allen B. Downey
Pro Perl

Pro Perl

Peter Wainwright

Publisher Resources

ISBN: 9781787282049Supplemental Content