Perl 6 at a Glance

N. B. Perl 6 has been renamed to Raku. Click to read more.


This book is about Perl 6, a programming language of the Perl family. It covers many basic and in-depth topics of the language and provides the initial knowledge you need to start working with Perl 6. The book does not require any previous experience with Perl, although some general understanding of programming is assumed.

Electronic edition
LeanPub
Amazon Kindle

Paperback editions
Amazon.comAmazon.de (and also on other local Amazon sites)

cover

Andrew Shitov. Perl 6 at a Glance

© Andrew Shitov, author, 2017
© Elizabeth Mattijsen, reviewer, 2017

Published online in October 2018

First published in English in January 2017

First published in Russian as a series of articles in the Pragmatic Perl magazine in 2014–2015, www.pragmaticperl.com

Published by DeepText, Amsterdam
www.deeptext.media

ISBN 978-90-821568-3-6

Navigate to the contents below or download the PDF version.


 

Book Contents

Foreword

Chapter 1. Perl 6 Essentials

Hello, World!

Variables

Sigils

Introspection

Twigils

Frequently used special variables

Built-in types

Typed variables

Bool

Int

Str

Array

Hash

Chapter 2. Operators in Perl 6

Prefixes

Prefix operators ! and not

Prefix operator +

Prefix operator –

Prefix operators ? and so

Prefix operator ~

Prefix operator ++

Prefix operator —

Prefix operator +^

Prefix operator ?^

Prefix operator ^

Prefix operator |

Prefix operator temp

Prefix operator let

Postfixes

Postfix operator ++

Postfix operator —

Method postfixes

Method postfix operator .

Method postfix operator .=

Method postfix operator .^

Method postfix operator .?

Method postfix operator .+

Method postfix operator .*

Infix operators

Numeric operators

Numeric operators +, -, *, and /

Numeric operator %

Numeric operators div and mod

Numeric operator %%

Numeric operators +&, +|, and +^

Numeric operators ?|, ?&, and ?^

Numeric operators +> and +<

Numeric operator gcd

Numeric operator lcm

Numeric operators == and !=

Numeric operators <. >, <=, >=, and <=> to compare numbers

String operators

String concatenation operator ~

String repetition operator x

String comparison operators eq and ne

String comparison operators lt, gt, le, and ge

String comparison operator leg

Universal comparison operators

Universal comparison operator cmp

Universal comparison operators before and after

Universal comparison operator eqv

Universal comparison operator ===

Universal comparison operator =:=

Smartmatch operator ~~

List operators

List repetition operator xx

Zip operator Z

Cross-product operator X

Sequence operator …

Junction operators

Junction operators |, &, and ^

Shortcut operators

Shortcut operator &&

Shortcut operator ||

Shortcut operator ^^

Shortcut operator //

Other infix operators

Infix operators min and max

Ternary operator ?? !!

Assignment operator =

Pair creation operator =>

List creation operator ,

Invocant call operator :

Meta-operators

Assignment meta-operator =

Negation meta-operator !

Reverse meta-operator R

Reduction meta-operator [ ]

Cross meta-operator X

Hyper-operators

Chapter 3. Code organisation

Subroutines, or subs

Non-value argument passing

Typed arguments

Optional parameters

Default values

Named arguments

Slurpy parameters and flattening

Nested subs

Anonymous subs

Variables and signatures

Lexical variables

state variables

Dynamic variables

Anonymous code blocks

Placeholders

Function overloading

Sub overloading with subtypes

Modules

Creating a module

Exporting a sub from a module

Using a module

Importing a module

The need keyword to use a module

The require keyword to use a module

Modules import summary

Chapter 4. Classes

Class attributes

Class methods

Inheritance

Multiple inheritance

Private (closed) methods

Submethods

Constructors

Roles

Chapter 5. New Concepts

Channels

Read and write

The list method

Transfer non-scalar objects

The closed method

Promises

Basics of promises

Factory methods

The start keyword

The in and at methods

The anyof and allof methods

The then method

An example of using promises: Sleep sort

Chapter 6. Regexes and Grammars

Regexes (regular expressions)

The match object $/

Grammars

A simple parser

An interpreter

Actions

AST (abstract syntax tree) and attributes

Creating a calculator

Appendix

Unicode

Whatever and WhateverCode (*)

Working with files and directories

Programming for the Internet

Database access

Conclusion

The book was published in the beginning of 2017 in paper and later as e-book, and was published online at andrewshitov.com in the end of 2018.

The content on this page is free of charge and may be used for any educational purposes.

Electronic edition
LeanPub
Amazon Kindle

Paperback editions
Amazon.comAmazon.de (and also on other local Amazon sites)