Intro    Chapter:   0. History   1. Design   2. Basic   3. Var   4. Op   5. IO   6. Block   7. Sub   8. OOP   9. Regex   10. Meta
Overview   Appendix:   A. Index   B. Grouped   C. Classtree   D. Delta   E. Exciting   F. FAQ   G. Glossary   H. Href



All variables in Perl begin with a sigil. They mark the 3 primary var types. The 4th sigil is for callables (routines) and the 5th is for boxes (namespaces) that organize the previous 4.

$ scalar, single value, can be of any data type
@ ordered array, indexed list of scalar
% unordered hash (associative array), 2 column table with unique IDs (keys) and associated values (value)
& code/rule/token/regex
:: abstraction: package/module/class/role/subset/enum/type/grammar

The first 4 can also be used as prefix operators, called contextualizers, that force different contexts, but there are much more different contexts then 4.


Twigil is short for secondary sigil. They follow after a primary sigil and mark special namespaces or variables with special meanings and properties.

$foo ordinary scoping (no twigil)
$.foo object attribute public accessor
$!foo object attribute private storage
$^foo self-declared formal positional parameter
$:foo self-declared formal named parameter
$*foo contextualizable global variable
$?foo compiler hint variable
$=foo pod variable
$~foo the foo sublanguage seen by the parser at this lexical spot

Special Variables

$_ context variable
$! error msg

Match Variables

$/ last created match object of this scope with these methods
$<...> alias to named capture, i.e., $/<...> or $/{'...'}
$0 ... alias to positional capture, like in P5 - $1 .. $9 but doesn't stop at $9
@() array that holds $0 .. $9 and rest and positional submatches

Global Variables

context variable, default global (run time), any of them are now objects with several methods

@*ARGS Arguments (Parameter) to a program (script), formerly @ARGV
$*ARGFILES magic command-line input handle
$*IN standard input handle (command line mostly)
$*OUT standard output (command line mostly)
$*ERR standard error output (command line mostly)
$*CWD current working directory (Str)
@*INC include pathes (but not for std library modules), formerly @INC
$*LANG LANG variable from %*ENV that defines what human language is used
%*ENV system environment variables, formerly %ENV
%*OPTS options from command line
$*TZ local time zone
$*PERL perl version running under, was formerly $^V or $]
$*KERNEL operating system running under
$*DISTRO OS distribution am I running under
$*PID ID of the running process,
$*GID real global ID of the running process owner, formerly @(
$*UID real user ID of the running process owner (user), formerly @<
$*EGID effective global ID, formerly @)
$*EUID effective user ID, formerly @>
$*ON_DIE exception handler, run befor die, formerly $SIG{__DIE__}
$*ON_WARN exception handler, run befor warn, formerly $SIG{__WARN__}

Compiler Hint Variables

compiler constants (fixed at compile time)

$?KERNEL for which operating System was this program compiled?
$?DISTRO Which OS distribution am I compiling under?
$?VM Which virtual machine am I compiling under
$?XVM Which virtual machine am I cross-compiling for
$?PERL Which Perl am I compiled for?
$?ENC current encoding
$?NF default string normalization method
%?LANG Hash of Grammar # What is the current set of interwoven languages?
$?GRAMMAR current grammar
$?FILE current filename of source file (FILE in P5)
$?MODULE current module
$?PACKAGE current package (PACKAGE)
$?CLASS current class
::?CLASS current class (as package name)
$?ROLE current role (as variable)
::?ROLE current role (as package or type name)
&?ROUTINE current sub or method (SUB)
&?BLOCK reference to current block
$?LINE current line number (LINE)

POD Variables

File-scoped POD data

$=pod surrounding POD object
$=data data block handle (=begin DATA ... =end)
@=COMMENT All the comment blocks in the file

Slang Variables

sublanguage seen by the parser at this lexical spot

$~MAIN the current main language (e.g. Perl statements)
$~Quote the current root of quoting language
$~Quasi the current root of quasiquoting language
$~Regex the current root of regex language
$~Trans the current root of transliteration language
$~P5Regex the current root of the Perl regex language


are builtins (not exactly variables and without a sigil) that return always the same important value

Name Value Meaning
e 2.71828182878434 euler number
i 0+1i imaginary number
pi 3.14159265394248 ratio of a circle's circumference to its diameter



The following pseudo-package names are reserved at the front of a name:

MY Symbols in the current lexical scope (aka $?SCOPE)
OUR Symbols in the current package (aka $?PACKAGE)
CORE Outermost lexical scope, definition of standard Perl
GLOBAL Interpreter-wide package symbols, really CORE::GLOBAL
PROCESS Process-related globals (superglobals), CORE::PROCESS
COMPILING Lexical symbols in the scope being compiled
DYNAMIC Contextual symbols in my or any caller's lexical scope

The following relative names are also reserved but may be used anywhere in a name:

CALLER Contextual symbols in the immediate caller's lexical scope
OUTER Symbols in the next outer lexical scope
UNIT Symbols in the outermost lexical scope of compilation unit
SETTING Lexical symbols in the unit's DSL (usually CORE)
PARENT Symbols in this package's parent package (or lexical scope)

The following is reserved at the beginning of method names in method calls:

SUPER Package symbols declared in inherited classes


my introduces lexically scoped names
state introduces lexically scoped but persistent names
our introduces package-scoped names
anon introduces names that aren't to be stored anywhere
has introduces object attribute names
augment adds definitions to an existing name
supersede replaces definitions of an existing name

Value Types

In Perl 6 any variable and value is an object. Here's a list of all different types of values, represented my different classes or roles. The routine types are in a different section.

Undefined types

Mu Most Undefined
Junction unordered superposition of data with and/or/one/none
Each ordered superposition (conjectural)
Failure Failure (lazy exceptions, thrown if not handled properly)
Any Perl 6 object (default routine parameter type, excludes junction)
Cool Perl 6 Convenient OO Loopbacks
Whatever Wildcard (like Any, but subject to do-what-I-mean via MMD)
Int Any Int object
Widget Any Widget object

Immutable types

Str Perl string (finite sequence of Unicode characters)
Bit Perl single bit (allows traits, aliasing, undef, etc.)
Int Perl integer (allows Inf/NaN, arbitrary precision, etc.)
Num Perl number (approximate Real, generally via floating point)
Rat Perl rational (exact Real, limited denominator)
FatRat Perl rational (unlimited precision in both parts)
Complex Perl complex number
Bool Perl boolean
Exception Perl exception
Block executable objects that have lexical scope
Range a pair of ordered endpoints
Set unordered collection of values that allows no duplicates
Bag unordered collection of values that allows duplicates
Enum an immutable Pair
EnumMap a mapping of Enums with no duplicate keys
Signature function parameters (left-hand side of a binding)
Parcel arguments in a comma list
LoL arguments in a semicolon list
Capture function call arguments (right-hand side of a binding)
Blob an undifferentiated mass of ints, an immutable Buf
Instant a point on the continuous atomic timeline
Duration difference between two Instants
HardRoutine a routine that is committed to not changing

Mutable types

Iterator Perl list
RangeIter Iterator over a Range
Scalar Perl scalar
Array Perl array
Hash Perl hash
KeySet KeyHash of Bool (does Set in list/array context)
KeyBag KeyHash of UInt (does Bag in list/array context)
Pair a single key-to-value association
Buf Perl buffer (a stringish array of memory locations)
IO Perl filehandle
Routine base class for all wrappable executable objects
Sub Perl subroutine
Method Perl method
Submethod Perl subroutine acting like a method
Macro Perl compile-time subroutine
Regex Perl pattern
Match Perl match, usually produced by applying a pattern, has these methods
Stash a symbol table hash (package, module, class, lexpad, etc)
SoftRoutine a routine that is committed to staying mutable

Low level data types

This is more low level than the last table. These types are more meant to give the compiler optimizing hints.

int32 (aka int on 32-bit machines)
int64 (aka int on 64-bit machines)
int128 (aka int on 128-bit machines)
uint1 (aka bit)
uint8 (aka byte)
num64 (aka num on most architectures)
complex64 (aka complex on most architectures)
buf8 aka buf, a "normal" byte buffer
buf16 a uint16 buffer
buf32 a uint32 buffer
buf64 a uint64 buffer

Object Introspection

Every value in P6 is an object and has following methods to tell more about itself.

WHAT short name of the class that an object belongs to
WHICH object ID (type)
WHO package, that support that object, long name in string context
WHERE memory address of the object
HOW object of meta class: "Higher Order Workings"
WHEN (reserved for events?)
WHY (reserved for documentation)
WHENCE autovivification of closures


Table of Precedence

all level of precedence

A Level Examples
N Terms 42 3.14 "eek" qq["foo"] $x :!verbose @$array
L Method postfix .meth .+ .? .* .() .[] .{} .<> .<<>> .:: .= .^ .:
N Autoincrement ++ --
R Exponentiation **
L Symbolic unary ! + - ~ ? | || +^ ~^ ?^ ^
L Multiplicative * / % %% +& +< +> ~& ~< ~> ?& div mod gcd lcm
L Additive + - +| +^ ~| ~^ ?| ?^
L Replication x xx
X Concatenation ~
X Junctive and & (&)
X Junctive or | ^ (|) (^) (-)
L Named unary sleep abs sin temp let
N Structural infix but does <=> leg cmp .. ..^ ^.. ^..^
C Chaining infix != == < <= > >= eq ne lt le gt ge ~~ === eqv !eqv
X Tight and &&
X Tight or || ^^ // min max
R Conditional ?? !! ff fff
R Item assignment = => += -= **= xx= .=
L Loose unary so not
X Comma operator , :
X List infix Z minmax X X~ X* Xeqv ...
R List prefix print push say die map substr ... [+] [*] any Z=
X Loose and and andthen
X Loose or or xor orelse
X Sequencer <== ==> <<== ==>>
N Terminator ; {...} unless extra ) ] }

Operator Associativity


  Assoc $a <op> $b <op> $c (infix op) <op>$a<op> (unary op)
L left ($a <op> $b) <op> $c (<op>$a)<op>
R right $a <op> ($b <op> $c) <op>($a <op>)
C chain ($a <op> $b) and ($b <op> $c)
X list infix:<op>($a; $b; $c)



These are the categories of the main language grammar, as stored in $~MAIN. The first category called "category" is the metacategory (for all slangs) that can be used to create new categories.

circumfix:<( )>
postcircumfix:<( )>


The default regex language as stored in $~Regex has following categories:



appear mostly before or around regular operators and give them different meaning or greater range. They can be nested like @a X[+=] @b, but be careful with that. In the example V stands for Value, L for left Value, and R for right. A number is the array index. Words in the second column are short explanation or an aliasing method if followed by ().

op= self assign known from P5, $L <op>= $R equals $L = $L op $R
!op negation known from P5, $L !<op> $R equals !($L op $R)
Rop reverse reverses the order of the operands
Sop sequence like reduction, only synchronous, execution in listed order is guaranteed; suppresses any explicit or implicit parallelism
>>op hyper processes arrays eager and in parallel or applies a single value to all array elements, @E = $L[0] op $R[0], $L[1] op $R[1], ...;
<<op hyper like above, points to the side which determines dimensionality, @E = $L[0] op $R[0], $L[1] op $R[1], ...;
[op] reduce() applies the operator between all elements of an array, $result = $V[0] op $V[1] op ...;
[\op] triangle() applies above reduction to a series of lists made of array slices ranging in length from 1 to the complete length of the original list, @result = $V[0], $V[0] op $V[1], $V[0] op $V[1] op $V[2], ...;
Xop crosswith() performs the operator to all the pairs of the Cartesian product of two arrays; @result = $L[0] op $R[0], $L[0] op $R[1], $L[1] op $R[0], $L[1] op $R[1]
Zop zipwith() like hyper, but evaluates lazy, @result = $L[0] op $R[0], $L[1] op $R[1], ...

Unicode operators

The two hyper operators and the evaluating autoquoting can be written with the unicode signs (also documented as "French Quotes") or with double lesser than or greater than signs (documented as "Texas Quotes").

« << Hyperop, right side dictates length of result
» >> Hyperop, left side dictates length of result
«» << >> qw with evaluation and quote protection


prefix operators or functions that forcing a context.

$() item() scalar/item context
? so() boolean
! not() negated bool context
+   numeric
-   negated num context
~   string
@() list() array/list context
  flat() flat list
  lol() list of list (once named slice context)
%() hash() hash context
&() code() code
|   flatten capture object into arglist (named parameter)
||   flatten capture object into semicolon list (positional parameter)


The infix ops in the first columns create junctions by combining two values (can be Junctions itself), the ops in second column are to be applied to a list as prefix op or method.

Junctive Infix Op Prefix Op Operation Meaning
& all AND True if all are True
^ one XOR True if exactly one is True
| any OR True if at least one is True
  none NOT any True if none are True


When ~~ is used as infix $_ is the left side, X is right. In when clauses just X is stated. Selection of the comparison alhorithm (4th column) is based on the value types as stated in the first two columns.

$_ X Type of Match Implied Match if (given $_)
Any True ~~ True (parsewarn)
Any False ~~ False match (parsewarn)
Any Match ~~ Successful match (parsewarn on literal token)
Any Nil ~~ Benign failure (parsewarn on literal token)
Any Failure Failure type check (okay, matches against type)
Any * block signature match block successfully binds to |$_ (flattened arglist)
Any Callable:($) item sub truth X($_)
Any Callable:() simple closure truth X() (ignoring $_)
Any Bool simple truth X
Any Match match success X
Any Nil benign failure X (treats Nil value as failure)
Any Failure malign failure X (passes Failure object through)
Any Numeric numeric equality +$_ == X
Any Stringy string equality ~$_ eq X
Any Whatever always matches True
Associative Pair test hash mapping $_{X.key} ~~ X.value
Any Pair test object attribute ?."{X.key}" = ?X.value (e.g. filetests)
Set Set identical sets $_ === X
Any Setty force set comparison $_.Set === X.Set
Bag Bag identical sets $_ === X
Any Baggy force bag comparison $_.Bag === X.Bag
Mix Mix identical sets $_ === X
Any Mixy force mix comparison $_.Mix === X.Mix
Associative Array keys/list are comparable +X == +$_ and $_{X.all}:exists
Positional Array arrays are comparable $_ «===» X (dwims * wildcards!)
Callable Positional list vs predicate so $_(X)
Any Positional lists are comparable $_[] «===» X[]
Hash Hash hash mapping equivalent $_ eqv X
Associative Hash force hash comparison $_.Hash eqv X
Pair Hash hash does mapping X{.key} ~~ .value
Positional Hash attempted any/all FAIL, point user to [].any and [].all for LHS
Callable Hash hash vs predicate so $_(X)
Any Hash hash contains object X.{$_}:exists
Str Regex string pattern match .match(X)
Associative Regex attempted reverse dwim FAIL, point user to any/all vs keys/values/pairs
Positional Regex attempted any/all/cat FAIL, point user to any/all/cat/join for LHS
Any Regex pattern match .match(X)
Range Range subset range !$_ or .bounds.all ~~ X (mod ^'s)
Any Range in real range X.min <= $_ <= X.max (mod ^'s)
Any Range in stringy range X.min le $_ le X.max (mod ^'s)
Any Range in generic range [!after] X.min,$_,X.max (etc.)
Any Type type membership $_.does(X)
Signature Signature sig compatibility $_ is a subset of X ???
Callable Signature sig compatibility $_.sig is a subset of X ???
Capture Signature parameters bindable $_ could bind to X (doesn't!)
Any Signature parameters bindable (pipe)$_ could bind to X (doesn't!)
Signature Capture parameters bindable X could bind to $_
Any Any scalars are identical $_ === X

Test Methods

They replace the Perl 5 filetest ops (like -e). Use it as in $filename.IO ~~ :X or $filename.IO.X.

:r file is readable by effective uid/gid
:w file is writeable by effective uid/gid
:x file is executable by effective uid/gid
:o file is owned by effective uid.
:R file is readable by real uid/gid
:W file is writeable by real uid/gid
:X file is executable by real uid/gid
:O file is owned by real uid.
:e file exists
:s file has size greater than zero
:f file is a plain file
:d file is a directory
:l file is a symbolic link
:p file is a named pipe (FIFO), or filehandle is a pipe
:S file is a socket
:b file is a block special file
:c file is a character special file
:t filehandle is opened to a tty
:u file has setuid bit set
:g file has setgid bit set
:k file has sticky bit set

Quoting Ops

The basic quoting operator (Q) does nothing, just taking literally what you quoted as a string. But with several adverbs, it behaves like the well known following ops:

Op Nonealphanumeric Version Translated Into Quoting Adverbs Method Version Meaning
q// ' ' Q :q //   single, simple nonevaluating quotes
qq// " " Q :qq //   double, evaluating quotes
qw// < > Q :q :w //   simple autoquotes (spaces divide words)
  << >> Q :qq :ww //   evaluating autoquotes with quote protection
qx//   Q :q :x //   command execution (system call) without evaluation
qqx//   Q :qq :x //   command execution (system call) with evaluation
qp//   Q :q :p //   paths
rx//   Q :regex //   regex
m//   Q :match // [ .match()](appendix-a-index#match) m atching
ms//   Q :match :sigspace //   matching, spaces divide words
s///   Q :subst /// [ .subst()](appendix-a-index#subst) s ubstitution
ss///   Q :subst :samespace /// & nbsp; su bstitution, spaces divide words
tr///   Q :trans /// [ .trans()](appendix-a-index#trans) [ transliteration](appendix-g-glossary#transliteration)
quasi {}   Q :code //   quasiquoting

Text Processing

Quoting Adverbs

There are a lot more adverbs to fine tune your quoting. The Adverbs can used with any quoting operator like: Q :s/.../ or qq :p /.../.

Short Long Meaning
:q :single interpolate \\ and \'
:qq :double interpolate with :s, :a, :h, :f, :c, :b
:s :scalar interpolate $ vars
:a :array interpolate @ vars
:h :hash interpolate % vars
:f :function interpolate & calls
:c :closure interpolate {...} expressions
:b :backslash interpolate \n, \t, etc. (implies :q at least)
:w :words split result on words (no quote protection)
:ww :quotewords split result on words (with quote protection)
:p :path return a path object (see S16 for more options)
:to :heredoc rarse result as heredoc terminator
:x :exec execute as command and return results
  :code quasiquoting
  :regex parse as regex
  :subst parse as substitution
  :trans parse as transliteration

Regex Modifier

Stay behind the regex op and change the behaviour of the regex, its search scope, etc. Most can also also put inside a subregex (in brackets).

Short Long Meaning
:g :global searches for any finding
:x(n)   searches n times (n is an int)
:nth(n) :st :nd :rd demands the nth finding, has many aliases for correct spelling (:2nd)
:c(n) :continue searches from nth position (counting from 0)
:p(n) :pos searches only on nth position (counting from 0)
:ov :overlap searches on all positionens just one time (activates backtracking)
:ex :exhaustive searches on all positions as long as it findes something (activates backtracking)
  :ratchet deactivates backtracking
  :panic overwriting of possible set :ratchet for all subrules (activates backtracking)
  :keepall subrules have to memorize everything
:rw   the regex has the right to change the string
:s :sigspace whitespace just separate parts of the Regex, don't stand for spaces to look for
:ss :samespace as in :s for substitutions, 1st part replaced with 1st part in second half a.s.o. (ss/teh hsa/the has/;)
:i :ignorecase no distinctions between uppercase and lowercase
:ii :samecase substitute with chars of same case as the matching
:m :ignoremark comparing base characters (Unicode non-mark characters) while ignoring any trailing mark characters
:mm :samemark substitute with chars that has same mark/accent pattern as the matched string
  :bytes searches on byte level
  :chars searches on character level (default)
  :codes matches between codepoints
  :graphs match language-independent graphemes
:P5 :Perl5 use the Perl 5 Regex syntax

Regex Metacharacter

. any character
^ begin of the sring
^^ begin of a line
$ end of the string
$$ end of a line
(...) group patterns and capture the result
[...] group patterns without capturing
{...} execute a closure (Perl 6 code) within a rule
<...> match a subrule (assertion
| match alternate patterns (logical OR with LTM)
|| match alternate patterns (sequential OR)
& match multiple patterns (AND)
** muliply this (meta)char/subrule times the following digit on right side
% match this (meta)char/subrule as long as separated by (meta)char/subrule on the right
%% like %, but allows trailing separator
\ escape a metacharacter to get a literal character, or escape a literal character to get a metacharacter
# mark a comment (to the end of the line)
:= bind the result of a match to a hypothetical variable


? zero or one
+ one o r more
* zero or more
** maxim al greedy matching
** mulip ly this (meta)char/subrule times the following digit on right side
**? minim al matching
% match this (meta)char/subrule as long as separated by (meta)char/subrule on the right
%% like %, but allows trailing separator

Control Chars

These Escape Sequences will be evaluated inside quotes to invisible control chars, if the ":b" aka ":backslash" quoting Adverbs is set (included in :quotewords and :double). They are also usable in regexes and thatswhy also included in the next list.

\t TAB

Escape Sequences

To be used just inside of regexes (rx/.../, m/.../, s/.../.../ and tr/.../.../).

\0[ ... ] character given in octal (brackets optional)
\c[ ... ] named character or control character
\C[ ... ] any character except the bracketed named or control character
\d digit
\D nondigit
\e escape character
\E anything but an escape character
\f form feed
\F anything but a form feed
\n (logical) newline
\N anything but a (logical) newline
\h horizontal whitespace
\H anything but horizontal whitespace
\L[ ... ] Everything within the brackets is lowercase
\Q[ ... ] all metacharacters within the brackets match as literal characters
\r return
\R anything but a return
\s any whitespace character, \h or \v
\S anything but whitespace
\t a tab
\T anything but a tab
\U[ ... ] everything within the brackets is uppercase
\v vertical whitespace
\V anything but vertical whitespace
\w word character (Unicode alphanumeric plus "_")
\W anything but a word character
\x[ ... ] character given in hexadecimal (brackets optional)
\X[ ... ] anything but the character given in hexadecimal (brackets optional)

Zero-Width Boundaries

zero-width boundaries begin with a pipe symbol. To negate put a ! in front of the pipe symbol.

<|c> codepoint boundary (always matches in grapheme/codepoint mode)
<|g> grapheme boundary (always matches in grapheme mode)
<|w> word boundary aka <wb>


predefined rules (see routine type rule) for any grammar or regex. They can have prefixes: . (dot) marks a non-capturing subrule, ? and ! are also non-capturing positive and negative zero width assertions.

<alpha> single alphabetic character
<upper> uppercase char
<lower> lowercase char
<digit> single digit
<xdigit> hexadecimal digit
<alnum> alphanumeric char, equivalent to <+alpha +digit>
<punct> punctuation char
<ident> an identifier
<print> printable char
<graph> "graphical" char like kanji
<cntrl> a control char
<blank> mostly a space or tab
<space> whitespace character aka
<ws> whitespace, roughly equals
<wb> zero-width word boundary, spot with between and
<ww> zero-width inside word spot between and
<?before pattern> zero-width lookahead
<!before pattern> negative zero-width lookahead, true if the pattern does not match
<?after pattern> zero-width lookbehind
<!after pattern> negative zero-width lookbehind
<?same> zero-width between two identical chars
<prior> last matched pattern
<?> matches nothing, always true
<!> always false

Match Object Methods

can also applied to any positional ($/[2][3].to) and named ($/<star>.from) submatch

$/.from the initial match position
$/.to the final match position
$/.chars $/.to - $/.from
$/.orig the original match string
$/.Str substr($/.orig, $/.from, $/.chars)
$/.ast the abstract result associated with this node
$/.caps sequential captures
$/.chunks sequential tokenization
$/.prematch $/.orig.substr(0, $/.from)
$/.postmatch $/.orig.substr($/.to)

Flow Control

Closure Traits

aka phasers. Every block can contain special named blocks (some are only for loops) that are started at certain times. They are traits (compile time property) of a block object. Those marked with a * can also be used within an expression as in BEGIN my $x = 3 * 3;.

BEGIN {...}* at compile time, ASAP, only ever runs once
CHECK {...}* at compile time, ALAP, only ever runs once
INIT {...}* at run time, ASAP, only ever runs once
END {...} at run time, ALAP, only ever runs once
ENTER {...}* at every block entry time, repeats on loop blocks.
LEAVE {...} at every block exit time
KEEP {...} at every successful block exit, part of LEAVE queue
UNDO {...} at every unsuccessful block exit, part of LEAVE queue
FIRST {...}* at loop initialization time, before any ENTER
NEXT {...} at loop continuation time, before any LEAVE
LAST {...} at loop termination time, after any LEAVE
PRE {...} assert precondition at every block entry, before ENTER
POST {...} assert postcondition at every block exit, after LEAVE
CATCH {...} catch exceptions, before LEAVE
CONTROL {...} catch control exceptions (like next/last/return etc), before LEAVE

Jump Commands

goto jump to a named label
redo repeat this loop turn
next skip to the next loop turn
last leave this loop now
succeed leave this when clause and surrounding given block
proceed check next when clauses
leave leave this block with a return value
return leave this routine with a return value


if when following expression evals in boolean context to True, the block that following after that will be executed
elsif works like if, but only recognized if no preceding "if" or "elsif" clause was executed
else following block will be executed, when no preceding "if" or "elsif" clause was executed
unless opposite of if, alias to if not, no "elsif" or "else" is allowed to follow
?? !! "cond ?? term1 !! term2" is short form "of if cond {term1} else {term2}"
ff awk style flip flop, in P5 .. in scalar context
fff sed style flip flop, in P5 ... in scalar context
given evals an expression into scalar context assignes it to $_ for the following block
when smartmatches an expression against $_; if the result is True, the following block will be executed
default following block will be executed, when no "when" clause was executed


loop general (endless) loop, unless used as an C-style-loop, evals following expression into void context
while loop with negative exit condition (exit when False), condition, evals expression into boolean context
until loop with positive exit condition(exit when True), evals expression into boolean context
repeat initial command for while or until loops that have their condtion at the end
do runs that block in any case one time, "do once"-loop
for evals expression into lazy list context and iterates over that list from first to last value, sets each time $_ (can be combined with when as well),


routine definition: [scope] [modifier] type [name] [trait] (signature) { block }

Routine Types

sub normal routine, named block with parmeters
method inheritable object methods
submethod not inheritable methods
regex routine that executes a regular expression
rule alias to regex :ratchet :sigspace
token alias to regex :ratchet
macro routine that is compiled to an AST at BEGIN (ASAP, compile time)
quasi block that is compiled to an AST at runtime

Routine Modifier

multi marks routines, which can have siblings with same name but different signature; when called, the one with matching sig is executed
only routines which don't allow siblings (this is default, you may leave it out)
proto fallback for multi, if no multi signature matches the caller, a proto with same name is executed

Routine Traits

phasers (closure traits) can also be seen as routine traits.

export this routine will be exported my the current module by default
will do block of code executed when the subroutine is called. Normally declared implicitly, by providing a block after the subroutine's signature definition
signature signature of a subroutine. Normally declared implicitly, by providing a parameter list and/or return type
as inner type constraint that a routine imposes on its return value
of official return type of the routine
cached marks a subroutine as being memoized
rw marks a subroutine as returning an lvalue
parsed macro is parsed once, is hygienic, only parsed can be used
reparsed macro parsed twice, not hygienic, later parsed can be used
tighter specifies the precedence of an operator higher than an existing operator as seen here
looser specifies the precedence of an operator lower than an existing operator as seen here
equiv specifies the precedence of an operator same as an existing operator as seen here
assoc specifies the associativity of an operator explicitly as seen here

Parameter Traits

as data coming through that parameter will be coerced to the type following as
readonly immutable parameter
rw mutable parameter (rw stands for: read write)
copy read-writable copy of the original argument ("pass-by-value")
dynamic parameter is an "environmental" variable, a lexical in the dynamic scope
parcel raw reference, will not be contextualized

Signature Symbols

In routine and block definitions can be also some character with special meaning

! suffix of required parameter (default when named, not positional)
* prefix of slurpy arrays
--> prefix of return type
-> prefix of named readonly parameters for a block (pointy block syntax)
: prefix of named parameter, positional when without
:: prefix of a variable type introduced in a signature
<-> prefix of named writeable parameters for a block (double pointy block syntax)
? suffix of optional parameter (default when positional, not named)
^ prefix of metaclass methods, $obj.^methods(); is shortcut for $obj.HOW.methods($obj);

Callframe Methods

A callframe object is generated at run-time for each call of a block of code. If a block of code includes a callframe() call, the value returned from that call is the callframe object corresponding to the block of code. To get the value of other blocks and routines higher in the call stack, use callframe with args, or caller, with or without args.

Once you have a callframe object, you can call the following methods on it:

args capture of args passed for this callframe
callframe callframe call which navigates relative to self
caller caller call which navigates relative to self
file source .file corresponding to callframe
hints compiler symbols in effect during originally compilation
inline did control structure create callframe (rather than user)
leave leave (return from) a particular callframe
line line number in source .file corresponding to callframe
my access to callframe's lexicals (read only)

Intro    Chapter:   0. History   1. Design   2. Basic   3. Var   4. Op   5. IO   6. Block   7. Sub   8. OOP   9. Regex   10. Meta
Overview   Appendix:   A. Index   B. Grouped   C. Classtree   D. Delta   E. Exciting   F. FAQ   G. Glossary   H. Href