1st law of language redesign: Everyone wants the colon for their particular syntax.2nd law of language redesign: Larry gets the colon for whatever he wants.

Basics doesn't mean here easy but fundamental. Which mostly translates to how to format and reformat data (numbers, strings and more).

Defaults

Please note that any Perl 6 source code is treated as unicode by default. Also use strict; and use warnings; are enabled implicitly. But the interpreter most likely also defaults to read code as Perl 5. To declare sources as Perl 6 you can write:

#!/usr/bin/perl6
use v6.0;
v6;

or just thast with keyword like module or class.

Statements

Unless you use blocks, a Perl program executes one statement after another in linear progression. They have to be separated by a semicolon (;), except before and after a closing curly brace, where it is optional.

Spaces and Indentation

Perl doesn't care about indentation. And spaces are still in many places without meaning. However these have become fewer.

Comments

Single Line

Like in Perl 5 and many other languages of its league a "#" tells the compiler to ignore the rest of the line.

Multi Line

#`( )

=begin comment
=end comment

POD

$=

Number Literals

Unlike strings, numbers don't need quoting. But if there is a non number character in it, there will be an error. Chars of a number definition are: (0-9,.,+,-,e,E,i,_) includind the radix prefixes: (0b,0o,0d,0x) and the prefix for version numbering (v). The + and act as operator that convert into the numerical context, which still means: take from left to right all digits and stop with the first none number character.

A single underscore is allowed only between any two digits, delimiter helping readability.

General Radix Form

Scientific Notation

Rational Number

To distinguish them from a division operation, you have to groupe them with braces.

(3/7)
(3/7).numerator
(3/7).denominator
(3/7).nude.perl

As always, .perl gives you an almost source like code formatting which results here in 3/7. Adding .nude you get (3/7), the nude source code. There are 2 different immutable value types representing both rational number. FatRat has unlimited precision and Rat has just enough to be evaled into a Real type. When you explicitly type a variable to one o them, the braces become optional.

Version Number

Quoting

Quoting is like regular expression a sublanguage inside the main language with it's own syntactical rules. It is parsed by a special grammar as to be found in the special variable$~Q. The operator with the same name (the generic quoting operator) does almost nothing, just provides a mechanism to mark the beginning and end of text sequence. The examples in this chapter use almost every time slashes for that purpose, but any not alphanumerical character or pair of matching (bracing) character can be used as well.

Inside of these delimiters, every character will be taken literally. Any additional meaning has to be added by quoting adverbs. Most of them have a short and a long name and some of the most useful have an additional syntax that replaces them altogether with the Q operator.

Single Quotes

No matter which string delimiter is chosen, sometimes he has to occur as a literal character inside the string too. In that case use single quotes with the adverb :single or one of the following aliases, from which ' ' ist maybe the best know. Its also the shortest and easy to understand, but don't allow to add other adverbs.

Q :single /.../;
Q :q /.../;
q /.../;
'...'

Inside single quotes the backslash (\) "quotes" meaning: he liberates the following character from his special meaning. Or to put it simple \\ translates (or interpolates) to \ and \' to '. For anything more you need additional adverbs.

Quote Words

Q :words /.../;
Q :w /.../;
qw/.../
<...>

Q :quotewords /.../;
Q :ww /.../;
<<>>

my @steps = <one two three>;

Heredocs

Are now normal quoted strings, only with a special delimiter.

Q :to 'EOT';
...
...
EOT

To make templates in which variables and closures are evaluated, take the normal double quote and just add the adverb for the heredoc delimiter or define with other adverbs what exactly you want to have evaluated.

pp:heredoc 'EOT';
EOT

Paths

Q :path /.../;
Q :p /.../;
qp /.../;

Regex

rx// aka Q :regex //
s/// aka Q :subst ///
tr/// aka Q :trans ///

Code

Q :exec /.../;
Q :x /.../;
qx /.../;

Q :code /.../;

Formating

perl

The .perl method is a built in Data::Dumper (pretty printer) which gives you structured data the way you write it in perl source code.