Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Perl 6 Deep Dive
Perl 6 Deep Dive

Perl 6 Deep Dive: Data manipulation, concurrency, functional programming, and more

eBook
€20.98 €29.99
Paperback
€36.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Table of content icon View table of contents Preview book icon Preview Book

Perl 6 Deep Dive

What is Perl 6?

In this chapter, we will examine the reasons why Perl 6 appeared and follow the history of the development of the language. You will see some examples of changes that have happened since Perl 5, and you will learn how to download and use the compiler, where to find the documentation, and how to run your first program in Perl 6.

In this chapter, we will cover the following topics:

  • Origins of Perl 6
  • Differences from Perl 5
  • Perl 6 resources
  • Compilers
  • Working with Rakudo Star
  • Writing our Hello World program

Origins of Perl 6

Perl 6 is a programming language from the Perl family. Perl itself emerged in 1987 and since then, it is constantly evolving: its current stable version is 5.26, which was released in May 2017. In 2000, Larry Wall, the creator of Perl, proposed to start working on the next version of the language—Perl 6.

There were a few reasons for that. First, a language should continue developing to reflect the new requirements of developers. Second, it may change the perception of Perl in the non-Perl community. The version 5.0 appeared in 1993 and despite that, the language has continued developing. The major version number was still 5 and in the eyes of many people, it meant that Perl was stalled since 1993. The new major version update would refresh the perception.

The idea was to make Perl 6 "the community rewrite of Perl". Larry asked the community to share what bits of Perl they wanted to change. That call for changes resulted in 361 RFC (Request for Comments) documents, which are published at https://perl6.org/archive/rfc/. These documents are only of historical interest as of today.

Later, the various proposals were systematically analyzed, grouped together by similar topics and published as a series of Synopses. The naming and numbering principle behind those documents were to keep the structure of the chapters of the Programming Perl book.

Later, Synopses were once again summarized and explained in a set of documents called Apocalypses and Exegeses. All these papers are available today at http://design.perl6.org, but again, they are not the final specification of the language, only a collection of historical documents.

Another important idea about Perl 6 was about the way compilers are created. In Perl 5, the language rules are indirectly defined by the single available compiler. Some bugs, or not obvious behavior of the compiler, may be considered as part of the language standard. In Perl 6, it was decided to have a clear language specification, and no reference compiler. There can be more than one compiler. The main requirement for them is implementing the specification and passing the set of tests.

Differences from Perl 5

Let's briefly look at some of the changes that happened on the way to Perl 6. In the following sections, you will see a few examples of code in Perl 5 and 6. They are intended for a general understanding of how Perl 5 transforms to Perl 6, but you are not expected to understand every bit of it. All the details about the syntax of Perl 6 will be explained later in this book.

Sigils

One of the most difficult things for the newcomers to Perl are sigils. A sigil is a character in front of the name of variables in Perl that denotes the structural type of a variable. For example, $ for scalar values, @ for arrays, and % for hashes.

The problem arises when you access an element of an array or hash. Let's consider the following lines of code as an example in Perl 5 of an array with the first few Fibonacci numbers:

my @fibonacci = (0, 1, 1, 2, 3, 5, 8, 13);
print $fibonacci[4];

First, a @fibonacci array is created. The name of the variable includes the @ character as a sigil. In the second line, we access one of the elements of that array and use another sigil, $, this time. This is because a single element of an array is a scalar, and scalars use $ as a sigil. For those who learn Perl, this small change in sigils is a big problem in understanding the basics of the language.

In Perl 6, sigils are unified and are part of the variable names. You do not change it independently, whether you access an element of an array or an array as a whole. The preceding example will look like this in Perl 6:

my @fibonacci = (0, 1, 1, 2, 3, 5, 8, 13);
print @fibonacci[4];

In both lines, the same sigil is used for the @fibonacci array and for its @fibonacci[4] element. This approach is much more consistent and easier for a beginner.

Signatures

In Perl 5, you had to extract the values of the arguments of a function yourself by using either the built-in shift function, or from the default @_ array.

Let's see this in the following example, with a function to calculate the sum of its two arguments. In Perl 5, you had to do some additional work to get the actual passed parameters.

First, get the argument values with shift in Perl 5:

sub add {
my $x = shift;
my $y = shift;
return $x + $y;
}

Then, by using the @_ array:

sub add {
my ($x, $y) = @_;
return $x + $y;
}

Unlike many other programming languages, it was not possible to declare a list of the function's formal parameters directly. For instance, this is how you do it in C or C++:

int add(int x, int y) {
    return x + y;
}

In Perl 5, it is possible to restrict the number of arguments and their structural types with the help of prototypes. Sigils are used there to tell Perl the type of the argument. The preceding function for addition may look like this in Perl 5:

sub add($$) {
    my ($x, $y) = @_;
    return $x + $y;
}

Using function prototypes will make the compiler complain when the function is used with the different number of arguments (say, one or three instead of two), but you still have to get their values yourself.

Perl 5.20 introduced function signatures. So, now, you may benefit from declaring the arguments in one go. The following code gives an example of such approach. Both $x and $y arguments are declared in the function header.

use v5.20;

use feature qw(signatures);
no warnings qw(experimental::signatures);

sub add($x, $y) {
    return $x + $y;
}

say add(4,5);

You will notice that you need to instruct Perl to use the features of Perl 5.20 by mentioning the minimal version number in the script. You will also notice that you must activate the corresponding feature by a separate instruction. However, even more, because signatures are an experimental feature, you have to manually disable the warning message to get a clean output.

In Perl 6, function signatures are allowed from the very beginning, so you may directly use it:

# This is Perl 6
sub add($x, $y) {
    return $x + $y;
}

Actually, signatures in Perl 5.20 are an example of backporting features from Perl 6 to Perl 5. So, despite the fact that Perl 6 was meant to be the next version of Perl 5, Perl 5 still gets some elements that were designed in Perl 6 to make Perl better.

Classes

To make the user experience better, let's take a look at another important example of where the syntax of Perl changes in Perl 6.

Traditionally, object-oriented programming is done in Perl 5 with the help of the so-called blessed hashes. Data members of an object are elements of the hash, and the blessed reference to that hash may be used to call a method on an instance of the class. The following example shows you what to do to define a class and create an instance of it in Perl 5:

package MyClass;

sub new {
    my ($class) = @_;
    my $this = {
        counter => 0
    };
    bless $this, $class;
    return $this;
}

sub inc {
    my ($this) = @_;
    $this->{counter}++;
    return $this->{counter};
}

1;

So far, the class named MyClass has two methods—new, to create a new instance, and inc, to increment the counter and return the new value. When dealing with Perl 5's classes, don't forget to return a true value at the end of the module, and that is the goal of the 1 in the last line of the file.

In the main program, you can use MyClass by creating an instance and calling methods on the variable as follows:

use MyClass;

my $var = MyClass->new;

print $var->inc, "\n";
print $var->inc, "\n";
print $var->inc, "\n";

The implementation of the object-oriented things in Perl 5 was another obstacle for newcomers who may have had an experience of working with classes in other languages but were confused by the way Perl 5 created them.

Classes in Perl 6 are way more familiar to developers who have worked with other object-oriented programming languages.

This is how you define the same class, as shown in the preceding example, in Perl 6:

class MyClass {
    has $!counter;      

    method inc() {
        $!counter++;
        return $!counter;
    }
}

As you see, the whole class is defined within the pair of braces. Its data members are explicitly declared with the has keyword, and there's no need to return 1 at the end of the file.

Now, create an object of the class and increment the internal counter three times, like we did in the Perl 5 example earlier. This is how you do it in Perl 6:

my $var = MyClass.new;

say $var.inc;
say $var.inc;
say $var.inc;

Do not focus on the details yet because it will all be explained in later chapters.

So far, we've seen three examples of where it was desired to improve the syntax of Perl 5.

To see more examples of changes between Perl 5 and Perl 6, you may refer to a few articles grouped under the title 'Perl 5 to Perl 6 guide' in the documentation of Perl 6 at https://docs.perl6.org/language.html, which is dedicated to that specific topic:

5to6-nutshell

Perl 5 to Perl 6, in a nutshell—How do I do what I used to do?

5to6-perlfunc Perl 5 to Perl 6 guide—functions
5to6-perlop Perl 5 to Perl 6 guide—operators
5to6-perlsyn Perl 5 to Perl 6 guide—syntax
5to6-perlvar Perl 5 to Perl 6 guide—special variables

Compatibility with Perl 5

Existing Perl 6 compilers cannot execute Perl 5 programs without modifications in the source code. Perl 5 and Perl 6 are sometimes called sister languages. Both share the same spirit of Perl, and, in many cases, it is possible to convert the program from Perl 5 to Perl 6.

One of the biggest advantages of Perl 5 is the CPAN (Comprehensive Perl Archive Network). It contains a myriad of modules for the immense number of areas. Most probably, your task is already solved by some author of CPAN. To use this useful heritage in your programs in Perl 6, you may want to use the Inline::Perl5 module, which allows using an existing Perl 5 module without modifying the source code.

For example, let's take one of the most popular modules in Perl 5, Text::CSV, and embed it in our program in Perl 6.

use Inline::Perl5;
use Text::CSV:from<Perl5>;

my $csv = Text::CSV.new;

$csv.parse('First name,Last name');
say $csv.fields.join("\t");

$csv.parse('Astrid,Lindgren');
say $csv.fields.join("\t");

With Inline::Perl5 enabled, the :from<Perl5> suffix loads the Text::CSV module from Perl 5 module directory. That module must be installed as a regular Perl 5 module from CPAN.

The rest of the program uses the $csv object, which is an instance of Text::CSV. Notice that you have to follow Perl 6 syntax, so, for instance, instead of creating the object with Text::CSV->new use Text::CSV.new. The same applies to calling the parse method: in Perl 5 it would be $csv->parse(), while in Perl 6 you use dot: $csv.parse(). Working with objects in Perl 6 is described in Chapter 8, Object-Oriented Programming.

Luckily, there is already a module Text::CSV for Perl 6. You can find it on the http://modules.perl6.org page. Using Inline::Perl5 can be very useful for those modules on CPAN, which do not yet have equivalents or replacement, written in Perl 6. For example, the following example taken from the module documentation shows how to connect to the database (of course, you need PostgreSQL to be installed to test the example):

use Inline::Perl5;
use DBI:from<Perl5>;

my $dbh = DBI.connect('dbi:Pg:database=test');
my $products = $dbh.selectall_arrayref(
'select * from products', {Slice => {}}
);

The Inline::Perl5 module is available at https://github.com/niner/Inline-Perl5.

Perl 6 resources

Perl 6 has a long history and many documents were created during that time, for instance, language ideas, draft specifications, and compiler documentation. Many enthusiasts wrote articles and blog posts about Perl 6. Some of that is outdated and does not reflect the current state of the language. In this chapter, I will give you a brief list of materials that are up-to-date and that you should use in your practice of working with Perl 6.

Documentation

The main entry point for documentation of the Perl 6 programming language is the Documentation section of Perl 6's site (http://docs.perl6.org). It contains a few sections with a comprehensive description of the types, operators, and built-in classes that are available in Perl 6. As the language is still developing, you may sometimes find places in the documentation where it does not reflect the current state of the language. In this case, you may consult the community of language developers or check the files from the test suite.

Test Suite

Perl 6's test suite, called Roast, can be found in the repository at https://github.com/perl6/roast. It contains thousands of tests covering many corners of Perl 6. The test suite is also a good place to look if you want to see ways you can write programs in Perl 6. It may be a long read sometimes, but many tests are checking the features from all possible angles.

In Roast, the tests are grouped in directories with names such as S32-io. These names correspond to the numbers of the Synopses, and are split into thematic sections. For example, for the Synopses 11 'Compilation Units', there exist three directories in testsS11-compunits, S11-modules, and S11-repository.

STD.pm

STD.pm is a huge file describing the formal Perl 6 grammar. The grammar of Perl 6 is written in Perl 6 itself. The repository of https://github.com/perl6/std contains the grammar and the viv utility that translates the grammar into the Perl 5 code. We have mentioned the STD.pm grammar because it may be interesting for those readers who want to dig deeper into the internal structure of the grammar. In the rest of this book, we will explain the grammar based on examples of code in Perl 6.

Community

The developers of Perl 6 traditionally use IRC for communication. You may also join the #perl6 channel to ask questions about the language or execute a piece of Perl 6 online.

To join the channel, follow the instructions listed on the https://perl6.org/community/ page.

If you want to run the code in IRC, refer to the rakudo bot as follows:

<me> rakudo: say "Hello, World!"
<+camelia> rakudo-moar cb8fa0: OUTPUT: «Hello, World!␤»

In the output, you can see that Rakudo is using the MoarVM backend by default. The string that was printed by the program is displayed after the OUTPUT keyword.

Use this feature carefully as the result of your requests will be visible to the whole room and also be logged. The best use case is to show the behavior of the compiler when you find a bug or when you see a different result from what is said in the documentation. The Perl 6 developers are always present in the IRC channel and will advise on what is wrong or will aim to fix the bug and make the documentation correct.

If you are on Facebook, visit the Perl 6 group here:
https://www.facebook.com/groups/1595443877388632/

In the offline, you will see many people who love Perl 6 at various conferences. Go to the Perl Conference (previously known as YAPC, (Yet Another Perl Conference)), which is held every year in Europe and in the USA. You may find more about them on http://theperlconference.org and http://www.yapc.eu. For many years, there were work Perl booths at the big open-source conferences like OSCON and FOSDEM. There are also many local conferences, workshops, and local group meetings. Find the closest group to your location at http://pm.org.

Compilers

During the process of Perl 6 development, a number of compilers were created. Some of them were just a playground to test some ideas, whereas some were more mature. Among the most important, we should mention the following four projects:

  • Parrot
  • Pugs
  • Perlito
  • Rakudo

There were more attempts to create a Perl 6 compiler, which were less successful or less complete. We will go through the preceding list to see the highlights of each project and then focus on Rakudo, which is the compiler you should use today.

Parrot

Parrot is the first virtual machine aimed to be the base of the Perl 6 compiler. The initial design of the language suggested that the source code is compiled to the bytecode, which is executed by the virtual machine. Parrot's goal was to create a virtual machine suitable for handling all the needs of Perl 6 from simple data types, such as integers, to more complicated structures, such as classes, with the ability to call methods on objects and follow the object hierarchy.

The project is available at parrot.org. After some time, Parrot started supporting other programming languages, such as Lua or Python, and the virtual machine became less focused on Perl 6 itself. For example, the Ponie project was an attempt to create a compiler that would execute Perl 5 programs using Parrot.

Parrot became one of the virtual machines inside another project, Rakudo. However, before we go to Rakudo, let's follow the historical path and talk about Pugs.

Pugs

Pugs (Perl User's Golfing System) is a Perl 6 compiler written in Haskell. It was started in 2005 by a sole developer and soon attracted more people to the team. Pugs was the most sophisticated compiler of its time. It was difficult and very time consuming to compile the project, the execution speed was low, but the quality of the compilation and the coverage of Perl 6 specification were outstanding.

Pugs main role in Perl 6 as of today is the vast test suite. It was created to test Pugs itself, but turned out to be an official test suite for Perl 6. A compiler that claims to call itself a Perl 6 compiler must pass the test suite tests.

Pugs are not developing anymore, but its source code is available on GitHub at https://github.com/perl6/Pugs.hs.

Perlito

Perlito is another very interesting example of a project of building a Perl 6 compiler. It was aimed at cross-compiling Perl 5 or Perl 6 to one of these languages—JavaScript, Java, Go, Python, Ruby, or Lisp. You can find the project's repository at https://github.com/fglock/Perlito.

Perlito offers a web interface to compile the subset of Perl 6 in the browser. It compiles the code in Perl 6 to JavaScript and executes it immediately. This page is available at http://fglock.github.io/Perlito/perlito/perlito6.html. This project covers the Perl 6 specification only partially, but it may still be used to create various online educational systems for both Perl 5 and 6.

Rakudo

Rakudo is a compiler initially built on the Parrot virtual machine. Later, it started using the Java Virtual Machine (JVM), but in the end, the developers of Parrot created their own virtual machine, MoarVM (Metamodel on a Runtime Virtual Machine (www.moarvm.org)). Currently, the support of JVM is limited, and the main virtual machine is MoarVM.

Rakudo itself is a Perl 6 compiler. For us, the most useful compiler is Rakudo Star, which is a distribution including the compiler as well as a number of Perl 6 modules and a few command-line tools, such as a module installer. In this book, we will use the Rakudo Star compiler to run programs in Perl 6.

Rakudo's website is rakudo.org.

Working with Rakudo Star

Rakudo is the most complete compiler available today. It supports the biggest subset of the Perl 6 language, and it would not be a mistake to say that Rakudo is the only compiler you should use to learn Perl 6.

Downloading and installing Rakudo Star

There are a few ways of installing Rakudo Star on your computer. You can either download the source code and compile it or download an installer for your platform. Rakudo Star is available for all major platforms, namely, Windows (both 32- and 64-bit versions), Mac OS X, and Linux.

The main download page of Rakudo Star is http://perl6.org/downloads. On that page, you will find links to the latest versions of the Rakudo Star distributions for different platforms and instructions on how to install them.

On Windows, the process is extremely simple. Just download the most recent version of the MSI installer, run it, and follow the instructions.

On Mac OS X, you either download a .dmg installer, or use the brew manager, as shown here:

$ brew install rakudo-star

On Linux, you have to install Rakudo Star from the source files.

After you have installed Rakudo Star, you will find the perl6 executable file in its bin directory. Make sure to add the path to that directory to your system-wide PATH variable so that you can type perl6 from any location.

In the rest of this book, we will assume that Rakudo Star is installed, and we will use the perl6 executable to run programs.

Command-line options

The Perl 6 compiler of Rakudo Star accepts a few command-line options. Let's take a look at some of them.

The -c command

The -c command-line checks the syntax of the program and exits. It also runs the BEGIN and CHECK blocks in the program, which are discussed in the section Phasers of Chapter 2, Writing Code later in this book. This command-line option is useful if you only want to check that there are no syntax errors in the code and don't want to execute it, with the exception being the code in the BEGIN and CHECK code blocks.

In the case of correct programming, it prints the following output:

Syntax OK

If there were compile-time errors, the compilation will stop at the first error and will display it on the console, mentioning the line number where it found an error.

The error message contains the description of the error and indicates the exact place in the code with the help of the eject character (). If your console supports colors, the fragment of the code before the eject character is green, and the rest of the line is red.

Here is an example of a program that misses the closing quote for the string:

say "Hello;

Run it to check the syntax, as shown here:

$ perl6 -c err.pl

The program did not compile, and this is what the compiler prints:

===SORRY!=== Error while compiling /Users/ash/code/err.pl
Unable to parse expression in double quotes; couldn't find final '"' 
at /Users/ash/code/err.pl:2
------> <BOL><EOL>
    expecting any of:
        argument list
        double quotes
        term

The --doc command

The --doc (notice the double hyphen) command-line extracts the documentation from the program and prints it. Here, the so-called Pod documentation is meant. We will cover the Pod syntax in Chapter 2, Writing Code.

Let's see the small program that includes the documentation inside itself:

=begin pod
=head1 Hello, World program
=item This program prints "Hello, World!"
=end pod

say "Hello, World!";

Run it with the --doc command-line option as follows:

$ perl6 --doc pod.pl

It will print only parts of the documentation. The code itself will not be executed:

 Hello, World program
 
   * This program prints "Hello, World!"

The -e command

The -e option allows you to pass the whole program in a command line. This is useful for short programs that do a few actions or, for example, for small tests when you check how things work in Perl 6.

Run it with the program enclosed in quotes:

$ perl6 -e'say "Hello"'

And this is the result you will see:

Hello

The -h and --help commands

The -h and --help commands print the text with a list of available command-line options.

The -n command

The -n command-line option creates a loop so that the program is executed once for every line of the text submitted to the input of the program.

It may be, for example, a one-line utility that prints the first letter of the strings from the STDIN input:

perl6 -n -e'print $_.substr(0, 1)' < file.txt

It will print the line composed from the first characters of the lines in file.txt.

The -p command

The -p command-line option acts like the previously described -n option, but it also prints the value of the default variable $_ at the end of each line. We will see the meaning of the default variable in the following chapters.

The -I  and -M commands

The -I and -M options are used to load modules into the program. The module's name is passed to the -M option and if necessary, the path to the module should be passed in the -I option.

The -v and --version command

The -v and --version options print the version of the current Perl 6 compiler as follows:

$ perl6 -v

At the time of writing, I am using Rakudo Star version 2017.01, and this is what the output looks like:

This is Rakudo version 2017.01 built on MoarVM version 2017.01 implementing Perl 6.c.

The important thing here, apart from the version itself, is the virtual machine that is used to execute Perl 6 (MoarVM, as shown earlier) and the version of the Perl 6 language specification (it is 6.c in this example).

The Rakudo Star versioning scheme uses the year and the month of the release date of the distributive. Rakudo is rapidly developing, so check the rakudo.org site regularly to get updates.

The --stagestats command

The --stagestats is a command-line option that is more Rakudo-specific than the others we have described earlier. It prints the time spent by the compiler at different stages of compiling and executing the program.

The output differs depending on whether you are running a program or checking its syntax with the -c command-line option. Let's first take a look at what is printed when the -c option is used:

$ perl6 --stagestats -c hello.pl

The output is as follows:

Stage start      :   0.000
Stage parse      :   0.107
Stage syntaxcheck: Syntax OK

Without the -c option, you will see more statistics, because the program will not only be compiled but also executed, as shown here:

$ perl6 --stagestats hello.pl

The regular output of the program is printed:

Stage start      :   0.000
Stage parse      :   0.327
Stage syntaxcheck:   0.000
Stage ast        :   0.000
Stage optimize   :   0.003
Stage mast       :   0.008
Stage mbc        :   0.000
Stage moar       :   0.000
Hello, World!

Writing our Hello World program

So far, as we have installed the Rakudo Star compiler, it's now time to create the first program in Perl 6. It will print Hello, World! and exit.

The program is really easy. All you need is a single line with the only instruction to call the built-in say function. It takes the string, prints it to the console, and adds a new line after it.

This is how the whole program looks:

say 'Hello, World!'

Save the code to the file, say, hello.pl, and pass it to the compiler as follows:

$ perl6 hello.pl

It will compile the program and immediately execute it. The result is the desired string on the screen:

Hello, World!

Notice that the output ends with a new line. This is the behavior of the built-in say function. Alternatively, we could use another method of printing the output, using the print built-in function. Unlike say, it will not add the new line at the end of the output, so you have to do it yourself by adding the special symbol \n:

print "Hello, World!\n"

Notice that this time, a pair of double quotes is used. Double quotes treat special characters such as \n differently compared to single quotes. Inside double quotes, the \n converts to a new line character. That will not happen in single quotes, and, in that case, \n will appear on the screen as a sequence of two characters, and \n.

Because the program contains only one line of code, it is not necessary to end it with a semicolon. However, you can always do that:

say "Hello, World!";

This program produces exactly the same output as before.

Summary

In this chapter, we looked briefly at what kind of programming language Perl 6 is and how it differs from its sister language, Perl 5. We looked at the history of Perl 6 and at different projects of the Perl 6 compilers. Finally, we installed Rakudo Star, the best compiler tool of today and created the first 'Hello, World!' program.

In the following chapter, we will look at how to organize the code in the program.

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • • Filled with practical examples, this comprehensive guide explores all aspects of Perl 6.
  • • Leverage the power of Perl 6 concurrency to develop responsive and high-performant software.
  • • Delves into various programming paradigms (such as Object Oriented, functional, and reactive) that can be adopted by Perl 6 developers to write effective code.

Description

Perl is a family of high-level, general-purpose, interpreted, dynamic programming languages consisting of Perl 5 and Perl 6. Perl 6 helps developers write concise and declarative code that is easy to maintain. This book is an end-to-end guide that will help non-Perl developers get to grips with the language and use it to solve real-world problems. Beginning with a brief introduction to Perl 6, the first module in the book will teach you how to write and execute basic programs. The second module delves into language constructs, where you will learn about the built-in data types, variables, operators, modules, subroutines, and so on available in Perl 6. Here the book also delves deeply into data manipulation (for example, strings and text files) and you will learn how to create safe and correct Perl 6 modules. You will learn to create software in Perl by following the Object Oriented Paradigm. The final module explains in detail the incredible concurrency support provided by Perl 6. Here you will also learn about regexes, functional programming, and reactive programming in Perl 6. By the end of the book, with the help of a number of examples that you can follow and immediately run, modify, and use in practice, you will be fully conversant with the benefits of Perl 6.

Who is this book for?

This book is for developers who would like to learn the Perl programming language. A basic knowledge of programming is assumed.

What you will learn

  • • Learn the background from which Perl 6 appeared and how it developed.
  • • How to use Rakudo to run your programs.
  • • Various Perl 6 built-in types and details about their behavior
  • • Understand how scalar variables, hash variables, and arrays work
  • • Create meta operators and hyper operators
  • • How classes work and how to build software based on the Object Oriented Paradigm
  • • How Perl 6 provides support for concurrency, functional programming, and reactive programming.
Estimated delivery fee Deliver to Estonia

Premium delivery 7 - 10 business days

€25.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Sep 11, 2017
Length: 402 pages
Edition : 1st
Language : English
ISBN-13 : 9781787282049
Category :
Languages :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Estimated delivery fee Deliver to Estonia

Premium delivery 7 - 10 business days

€25.95
(Includes tracking information)

Product Details

Publication date : Sep 11, 2017
Length: 402 pages
Edition : 1st
Language : English
ISBN-13 : 9781787282049
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 110.97
Mastering Assembly Programming
€36.99
Perl 6 Deep Dive
€36.99
Mastering Bash
€36.99
Total 110.97 Stars icon

Table of Contents

15 Chapters
What is Perl 6? Chevron down icon Chevron up icon
Writing Code Chevron down icon Chevron up icon
Working with Variables and Built-in Data Types Chevron down icon Chevron up icon
Working with Operators Chevron down icon Chevron up icon
Control Flow Chevron down icon Chevron up icon
Subroutines Chevron down icon Chevron up icon
Modules Chevron down icon Chevron up icon
Object-Oriented Programming Chevron down icon Chevron up icon
Input and Output Chevron down icon Chevron up icon
Working with Exceptions Chevron down icon Chevron up icon
Regexes Chevron down icon Chevron up icon
Grammars Chevron down icon Chevron up icon
Concurrent Programming Chevron down icon Chevron up icon
Functional Programming Chevron down icon Chevron up icon
Reactive Programming Chevron down icon Chevron up icon

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
(4 Ratings)
5 star 25%
4 star 25%
3 star 0%
2 star 25%
1 star 25%
Amazon Customer Nov 26, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Excellent product
Amazon Verified review Amazon
Christian BELOSCAR Jan 24, 2018
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Cet ouvrage est assez complet sans être bien sûr exhaustif,il permettra à ceux qui programment dans un autre langage ou en Perl 5d'apprendre rapidement les nouveaux atouts de ce langage.Il est constellé d'exemples très simples pour illustrer le propos.Pas recommandé pour les débutants en programmation;pour ceux-ci je recommande vivement "ThinkPerl6" de Laurent Rosenfelddont il existe peut-être déjà une version en français ou qui ne saurait trop tarder.
Amazon Verified review Amazon
Anon Oct 24, 2017
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
I bought this book on Packt.com so that I could get the ebook and paper copy, but I cannot recommend it in it’s current state. There are many errors in the text and I feel I can no longer effectively learn from it. I believe the book may have been translated from a different language as there are many grammatical errors (which I was willing to overlook), but there are also many code errors. I have done my best to submit errata for the errors that I could not overlook, but this was an expensive book and I do not believe it should be sold it in its current state. With some more review and editing I believe this can become an excellent book. I like the organization and feature-based approach.Update: I just want to mention how pleasant dealing with Packt customer service was. I contacted them with my comments on the book and they gave me a full refund. They said that they were a print on demand business and I did not even have to return the book. Really great company.
Amazon Verified review Amazon
Gregory C. Donald Nov 01, 2019
Full star icon Empty star icon Empty star icon Empty star icon Empty star icon 1
This book is not a "deep dive". I found more in-depth coverage in Brian D Foy's "Learning Perl 6" book. There was nothing in there for meta-programming for example, and topics were not covered in much detail. Feels like it was written in a hurry.The book is in English but does not appear to have been written by a native English speaker, or perhaps it was poorly translated? I found many times thinking "that's an odd choice of words".I did not care for the many Perl 5 comparisons. They were a complete waste of time and space for me personally.Not a lot of value for the price I paid.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela