Perl 6
Perl 6 Lookup Tablet: Revision 292
"Overview"[Perl 6 Tablets] - _Chapter:_ "0:History"[Perl 6 History Tablet], "1:Design"[Perl 6 Language Design Tablet], "2:Basics"[Perl 6 Basics Tablet], "3:Var"[Perl 6 Variable Tablet], "4:Op"[Perl 6 Operator Tablet], "5:IO"[Perl 6 IO Tablet], "6:{}"[Perl 6 Block Tablet], "7:Sub"[Perl 6 Subroutine Tablet], "8:OOP"[Perl 6 OOP Tablet], "9:Rx"[Perl 6 Regex Tablet], "10:Meta"[Perl 6 Meta Tablet]
"Intro"[Perl 6 Intro Tablet] - _Appendices:_ "A:Index"[Perl 6 Index Tablet], *"B:Tables"[Perl 6 Lookup Tablet]*, "C:Cook"[Perl 6 Cookbook Tablet], "D:Delta"[Perl 6 Delta Tablet], "E:Best of"[Best Of Perl 6 Tablet], "F:Links"[Perl 6 Links Tablet]

----

{toc: }

^^ Variables

^^^ Sigils

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 layers (namespaces) that organize the previous 4.

> "$"{link: [Perl 6 Index Tablet]dollar sigil}. . . . "scalar"{link: [Perl 6 Variable Tablet]scalar}, single value, can be of any data type
> "@"{link: [Perl 6 Index Tablet]at sigil} . . . ordered "array"{link: [Perl 6 Variable Tablet]array}, indexed list of scalar
> "%"{link: [Perl 6 Index Tablet]percent sigil} . . . unordered "hash"{link: [Perl 6 Variable Tablet]hash} (associative array), 2 column table with unique IDs (keys) and associated values (value)
> "&"{link: [Perl 6 Index Tablet]ampersand sigil}. . . . code/rule/token/regex
> "::"{link: [Perl 6 Index Tablet]colon colon sigil} . . . abstraction: package/module/class/role/subset/enum/type/grammar

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

^^^ Twigils

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"{link: [Perl 6 Index Tablet]dot twigil}. . . object attribute public accessor
> "$!foo"{link: [Perl 6 Index Tablet]exclamation mark twigil}. . . object attribute private storage
> "$^foo"{link: [Perl 6 Index Tablet]caret twigil} . . self-declared formal positional parameter
> "$:foo"{link: [Perl 6 Index Tablet]colon twigil} . . .self-declared formal named parameter
> "$*foo"{link: [Perl 6 Index Tablet]asterisk twigil} . . .contextualizable global variable
> "$?foo"{link: [Perl 6 Index Tablet]question mark twigil} . . .compiler hint variable
> "$=foo"{link: [Perl 6 Index Tablet]equal sign twigil} . . .pod variable
> "$<foo>"{link: [Perl 6 Index Tablet]angle brackets twigil} . .match variable, short for $/<foo> or even $/{'foo'}
> "$~foo"{link: [Perl 6 Index Tablet]tilde twigil} . . .the foo sublanguage seen by the parser at this lexical spot

^^^ Special Variables

> "$_"{link: [Perl 6 Index Tablet] context var}. . . . . . . . . context variable
> "$!"{link: [Perl 6 Index Tablet] exclamation mark var} . . . . . . . . . error msg

^^^^ Match Variables

> "$/"{link: [Perl 6 Index Tablet] slash var} . . . . . . . . . last created match object of this block
> "$<...>"{link: [Perl 6 Index Tablet] angle brackets var} . . . . . . alias to named capture, see Twigils above
> "$0 .. $9"{link: [Perl 6 Index Tablet] 0 var} . . . . . alias to positional capture (most like in P5 - $1 .. $9)
> "@()"{link: [Perl 6 Index Tablet] round brackets var} . . . . . . . . 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"{link: [Perl 6 Index Tablet] args global var} . . . . . Arguments (Parameter) to a program (script), formerly @ARGV
> "$*ARGFILES"{link: [Perl 6 Index Tablet] argfiles global var}. . . magic command-line input handle
> "$*IN"{link: [Perl 6 Index Tablet] in global var}. . . . . . . . standard input handle (command line mostly)
> "$*OUT"{link: [Perl 6 Index Tablet] out global var}. . . . . . . standard output (command line mostly)
> "$*ERR"{link: [Perl 6 Index Tablet] err global var}. . . . . . . standard error output (command line mostly)
> "$*CWD"{link: [Perl 6 Index Tablet] cwd global var} . . . . . . current working directory (Str)
> "@*INC"{link: [Perl 6 Index Tablet] inc global var}. . . . . . . include pathes (but not for std library modules), formerly @INC
> "$*LANG"{link: [Perl 6 Index Tablet] lang global var} . . . . . . LANG variable from %*ENV that defines what human language is used
> "%*ENV"{link: [Perl 6 Index Tablet] env global var} . . . . . . system environment variables, formerly %ENV
> "%*OPTS"{link: [Perl 6 Index Tablet] opts global var} . . . . . options from command line
> "$*TZ"{link: [Perl 6 Index Tablet] tz global var}. . . . . . . . local time zone
> "$*EXECUTABLE_NAME"{link: [Perl 6 Index Tablet] executable name global var} . former $0
> "$*PERL"{link: [Perl 6 Index Tablet] perl global var} . . . . . . perl version running under, was formerly $^V or $]
> "$*KERNEL"{link: [Perl 6 Index Tablet] kernel global var} . . . . operating system running under
> "$*DISTRO"{link: [Perl 6 Index Tablet] distro global var} . . . . OS distribution am I running under
> "$*PID"{link: [Perl 6 Index Tablet] pid global var} . . . . . . . ID of the running process,
> "$*GID"{link: [Perl 6 Index Tablet] gid global var} . . . . . . . real global ID of the running process owner, formerly @(
> "$*UID"{link: [Perl 6 Index Tablet] uid global var} . . . . . . . real user ID of the running process owner (user), formerly @<
> "$*EGID"{link: [Perl 6 Index Tablet] egid global var} . . . . . . effective global ID, formerly @)
> "$*EUID"{link: [Perl 6 Index Tablet] euid global var} . . . . . . effective user ID, formerly @>
> $*ON_DIE . . . . exception handler, run befor die, formerly $SIG{__DIE__}
> $*ON_WARN. . . exception handler, run befor warn, formerly $SIG{__WARN__}
> $*COMPILING. . .
> $*EMERGENCY_MEMORY. . . formerly $^M
> $*DEBUGGING . .

^^^^ Compiler Hint Variables

compiler constants (fixed at compile time)

> "$?KERNEL"{link: [Perl 6 Index Tablet] kernel compiler var} . . . . . for which operating System was this program compiled?
> "$?DISTRO"{link: [Perl 6 Index Tablet] distro compiler var} . . . . . Which OS distribution am I compiling under?
> "$?VM"{link: [Perl 6 Index Tablet] vm compiler var} . . . . . . . . Which virtual machine am I compiling under
> $?XVM . . . . . . . Which virtual machine am I cross-compiling for
> "$?PERL"{link: [Perl 6 Index Tablet] perl compiler var} . . . . . . . Which Perl am I compiled for?
> "%?LANG"{link: [Perl 6 Index Tablet] lang compiler var} . . . . . . Hash of Grammar # What is the current set of interwoven languages?
> "$?GRAMMAR"{link: [Perl 6 Index Tablet] grammar compiler var}. . . . current grammar
> "$?FILE"{link: [Perl 6 Index Tablet] file compiler var}. . . . . . . . current filename of source file
> "$?MODULE"{link: [Perl 6 Index Tablet] module compiler var}. . . . . current module
> "$?PACKAGE"{link: [Perl 6 Index Tablet] package compiler var} . . . . current package
> "$?CLASS"{link: [Perl 6 Index Tablet] class compiler var} . . . . . . current class
> "::?CLASS"{link: [Perl 6 Index Tablet] class package compiler var}. . . . . . current class (as package name)
> "$?ROLE"{link: [Perl 6 Index Tablet] role compiler var} . . . . . . . current role (as variable)
> "::?ROLE"{link: [Perl 6 Index Tablet] role package compiler var}. . . . . . . current role (as package or type name)
> "&?ROUTINE"{link: [Perl 6 Index Tablet] routine compiler var}. . . . . current sub or method
> "&?BLOCK"{link: [Perl 6 Index Tablet] block compiler var} . . . . . . reference to current block
> "$?LINE"{link: [Perl 6 Index Tablet] line compiler var}. . . . . . . . current line number

^^^^ POD Variables

File-scoped "POD"{link: [perl_6_basics_tablet] pod} data

> "$=pod"{link: [Perl 6 Index Tablet] pod pod var} . . . . . . . surrounding POD object
> "$=data"{link: [Perl 6 Index Tablet] data pod var}. . . . . . . data block handle (=begin DATA ... =end)
> "@=COMMENT"{link: [Perl 6 Index Tablet] comment pod var}. . . All the comment blocks in the file

^^^^ Slang Variables

sublanguage seen by the parser at this lexical spot

> "$~MAIN"{link: [Perl 6 Index Tablet] main lang var} . . . . . . the current main language (e.g. Perl statements)
> "$~Quote"{link: [Perl 6 Index Tablet] q lang var}. . . . . . the current root of quoting language
> "$~Quasi"{link: [Perl 6 Index Tablet] quasi lang var} . . . . . . the current root of quasiquoting language
> "$~Regex"{link: [Perl 6 Index Tablet] regex lang var}. . . . . . the current root of regex language
> "$~Trans"{link: [Perl 6 Index Tablet] trans lang var} . . . . . . the current root of transliteration language
> "$~P5Regex"{link: [Perl 6 Index Tablet] p5regex lang var} . . . . the current root of the Perl regex language

^^^ Scope Declarator

> "my"{link: [Perl 6 Index Tablet] my} . . . . . . . introduces lexically scoped names
> "state"{link: [Perl 6 Index Tablet] state} . . . . . . introduces lexically scoped but persistent names
> "our"{link: [Perl 6 Index Tablet] our} . . . . . . . introduces package-scoped names
> "anon"{link: [Perl 6 Index Tablet] anon} . . . . . . introduces names that aren't to be stored anywhere
> "has"{link: [Perl 6 Index Tablet] has} . . . . . . . introduces object attribute names
> "augment"{link: [Perl 6 Index Tablet] augment}. . . . adds definitions to an existing name
> "supersede"{link: [Perl 6 Index Tablet] supersede}. . . replaces definitions of an existing name

^^^ Scopes

> 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

^^^ 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"{link: routine_types} are in a different section.

^^^^ Undefined types

> Mu. . . . . . . . Most Undefined
> 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 scopes
> Seq . . . . . A list of values (can be generated lazily)
> 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 (or equiv, like Z)
> Capture . . . Function call arguments (right-hand side of a binding)
> Blob . . . . . An undifferentiated mass of bits
> Instant. . . . A point on the continuous atomic timeline
> Duration. . . The difference between two Instants
> HardRoutine A routine that is committed to not changing

^^^^ Mutable types

> Iterator . . . . Perl list
> SeqIter . . . . Iterator over a Seq
> 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
> PairSeq . . . . A Seq of Pairs
> 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
> 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.

> int1. . . . . . .
> int2. . . . . . .
> int4. . . . . . .
> int8. . . . . . .
> int16 . . . . . .
> int32. . . . . . (aka int on 32-bit machines)
> int64. . . . . . (aka int on 64-bit machines)
> int128. . . . . (aka int on 128-bit machines)
> uint1. . . . . . (aka bit)
> uint2. . . . . .
> uint4. . . . . .
> uint8. . . . . . (aka byte)
> uint16 . . . . .
> uint32 . . . . .
> uint64 . . . . .
> uint128. . . . .
> num16 . . . . .
> num32 . . . . .
> num64 . . . . . (aka num on most architectures)
> num128 . . . .
> complex16 . .
> complex32 . .
> complex64 . . (aka complex on most architectures)
> complex128 .
> rat8. . . . . . .
> rat16. . . . . .
> rat32. . . . . .
> rat64. . . . . .
> rat128. . . . .
> buf8 . . . . . . aka buf, a "normal" byte buffer
> buf16 . . . . . a uint16 buffer
> buf32 . . . . . a uint32 buffer
> buf64 . . . . . a uint64 buffer

^^^ Object Introspection

> 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

^^ Operators

^^^ Table 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 | Meaning of $a ! $b ! $c |
| L | left | ($a ! $b) ! $c |
| R | right | $a ! ($b ! $c) |
| N | non | ILLEGAL |
| C | chain | ($a ! $b) and ($b ! $c) |
| X | list | infix:<!>($a; $b; $c) |

^^^ Categories

^^^^ Main

These are the categories of the main language grammar. The first category is the metacategory that can used to produce new ones. Sublanguages such as quoting and regexes can provide their own.

> category:<prefix>
> circumfix:<( )>
> dotty:<.>
> infix:<+>
> infix_circumfix_meta_operator:{'«','»'}
> infix_postfix_meta_operator:<=>
> infix_prefix_meta_operator:<!>
> package_declarator:<class>
> postcircumfix:<( )>
> postfix:<++>
> postfix_prefix_meta_operator:{'»'}
> prefix:<++>
> {{prefix_circumfix_meta_operator:{'[',']'} }}
> prefix_postfix_meta_operator:{'«'}
> quote:<q>
> routine_declarator:<sub>
> scope_declarator:<my>
> sigil:<$>
> special_variable:<$!>
> statement_control:<if>
> statement_mod_cond:<if>
> statement_mod_loop:<while>
> statement_prefix:<do>
> term:<*>
> trait_auxiliary:<is>
> trait_verb:<of>
> twigil:<?>
> type_declarator:<subset>

^^^^ Regex

The Regex language has following categories:

> assertion:sym<!>
> backslash:sym<w>
> metachar:sym<.>
> mod_internal:sym<P5>
> quantifier:sym<*>

^^^ Metaoperators

M. 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 can be written with the Unicode "chevron" signs (also documented as "French Quotes") or with double less than or greater than signs (documented as "Texas Quotes").

> « aka {{<<}}
> » aka {{>>}}

^^^ Contextualizers

Infix operator or functions that forcing a context.

> $(). . . . item(). . . . . "scalar/item context"{link: [Perl 6 Variable Tablet] Scalar}
> ? . . . . . so(). . . . . . "boolean"{link: [Perl 6 Operator Tablet] bool context}
> ! . . . . . not() . . . . . negated bool context
> +. . . . . . . . . . . . . . "numeric"{link: [Perl 6 Operator Tablet] numeric context}
> - . . . . . . . . . . . . . . negated num context
> ~. . . . . . . . . . . . . . "string"{link: [Perl 6 Operator Tablet] string context}
> @() . . . list() . . . . . "array/list context"{link: [Perl 6 Variable Tablet] Array}
> . . . . . . flat() . . . . . flat list
> . . . . . . lol(). . . . . . list of list (was slice context before)
> %() . . . hash() . . . . "hash context"{link: [Perl 6 Variable Tablet] Hash}
> &(). . . . code() . . . . "coderef"{link: [Perl 6 Variable Tablet] Callable}, "routines"{link: Routines}
> | . . . . . . . . . . . . . . flatten "capture"{link: [Perl 6 Variable Tablet] capture} object into arglist (named parameter)
> ||. . . . . . . . . . . . . . flatten "capture"{link: [Perl 6 Variable Tablet] capture} object into semicolon list (positional parameter)

^^^ Smartmatch

When 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"{link: 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 | * | block signature match | block successfully binds to (pipe)$_ (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 | Numeric | numeric equality | {{+$_ = X}} |
| Any | Stringy | string equality | {{~$_ eq X}} |
| Any | Whatever | always matches | True |
| Any | Nil | is nil | $_ === Nil |
| Hash | 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 |
| Hash | Set | hash keys same set | $_.keys === X |
| Any | Set | force set comparison | Set($_) === X |
| Array | Array | arrays are comparable | $_ «===» X (dwims * wildcards!) |
| Set | Array | array equiv to set | $_ === Set(X) |
| Any | Array | lists are comparable | @$_ «===» X |
| Hash | Hash | hash keys same set | $_.keys === X.keys |
| Set | Hash | hash keys same set | $_ === X.keys |
| Array | Hash | hash slice existence | X.{any @$_}:exists |
| Regex | Hash | hash key grep | any(X.keys).match($_) |
| Cool | Hash | hash entry existence | X.{$_}:exists |
| Any | Hash | hash slice existence | X.{any @$_}:exists |
| Str | Regex | string pattern match | .match(X) |
| Hash | Regex | hash key "boolean grep" | .any.match(X) |
| Array | Regex | array "boolean grep" | .any.match(X) |
| Any | Regex | pattern match | .match(X) |
| Num | Range | in numeric range | X.min <= $_ <= X.max (mod ^'s) |
| Str | Range | in string range | X.min le $_ le X.max (mod ^'s) |
| Range | Range | subset range | !$_ or .bounds.all ~~ X (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!) |
| Any | Any | scalars are identical | $_ === X |

^^^ Filetest Ops

Use it as in "$file.:X" or "$file ~~ :X". (NOTE 2010-11-07: in rakudo this is "$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 0
> .
> :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"{link: [perl_6_basics_tablet]quoting} (Q) does nothing, just taking literally what you quoted as a string. But with several adverbs, it behaves like the well known following ops:

| q// | Q :q // |
| ' ' | Q :q // |
| qq// | Q :qq // |
| " " | Q :qq // |
| qw// | Q :q :w // |
| {{< >}} | Q :q :w // |
| {{<< >>}} | Q :qq :ww // |
| qp// | Q :path // |
| qx// | Q :exec // |
| rx// | Q :regex // |
| m// | Q :match // |
| ms// | Q :match :sigspace // |
| s/// | Q :subst /// |
| ss/// | Q :subst :samespace /// |
| tr/// | Q :trans /// |
| quasi {} | Q :code // |

^^ 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 \\, \q and \' (or whatever) |
| :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."{link: Escape Sequences} (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 | Parse 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, search scope, etc.

| 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 old Regex |

^^^ 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 (logigical 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

^^^ Quantifier

> ? _______ zero or one
> + _______ one or more
> * _______ zero or more
> ** ______ maximal greedy matching
> ** ______ muliply this (meta)char/subrule times the following digit on right side
> **? _____ minimal 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.

> \a . . . . . . . . BELL
> \b . . . . . . . . BACKSPACE
> \e . . . . . . . . ESCAPE
> \f . . . . . . . . FORM FEED
> \n . . . . . . . . LINE FEED
> \r . . . . . . . . CARRIAGE RETURN
> \t . . . . . . . . TAB

^^^ Escape Sequences

To be used just inside of regexes (m/.../, s/.../.../ and tr/.../.../ and methods like comb('...')).

> \0[ ... ] . . character given in octal (brackets optional)
> \b . . . . . . word boundary
> \B . . . . . . Match when not on a word boundary
> \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
> \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 begin with a pipe symbol

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

^^^ Subrules

predefined rules (see "routine type"{link: Routine Types} 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>. . . . . . . . control char, e.g. newline and backspace
> <blank> . . . . . . . mostly a space or tab
> <space> . . . . . . . whitespace character aka \s
> <ws> . . . . . . . . . whitespace, roughly equals \s*
> <wb> . . . . . . . . . zero-width word boundary, spot with between \w and \W
> <ww>. . . . . . . . . zero-width inside word spot between \w and \w
> <?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

^^ 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"{link: [Perl 6 Index Tablet]BEGIN phaser} {...}*. . . at compile time, ASAP, only ever runs once
> "CHECK"{link: [Perl 6 Index Tablet]CHECK phaser} {...}* . . at compile time, ALAP, only ever runs once
> .
> "INIT"{link: [Perl 6 Index Tablet]INIT phaser} {...}*. . . . at run time, ASAP, only ever runs once
> "END"{link: [Perl 6 Index Tablet]END phaser} {...}. . . . . at run time, ALAP, only ever runs once
> .
> "START"{link: [Perl 6 Index Tablet]START phaser} {...}* . . on first ever execution, once per closure clone
> "ENTER"{link: [Perl 6 Index Tablet]ENTER phaser} {...}* . . at every block entry time, repeats on loop blocks.
> "LEAVE"{link: [Perl 6 Index Tablet]LEAVE phaser} {...} . . . at every block exit time
> "KEEP"{link: [Perl 6 Index Tablet]KEEP phaser} {...} . . . . at every successful block exit, part of LEAVE queue
> "UNDO"{link: [Perl 6 Index Tablet]UNDO phaser} {...}. . . . at every unsuccessful block exit, part of LEAVE queue
> .
> "FIRST"{link: [Perl 6 Index Tablet]FIRST phaser} {...}*. . . at loop initialization time, before any ENTER
> "NEXT"{link: [Perl 6 Index Tablet]NEXT phaser} {...} . . . . at loop continuation time, before any LEAVE
> "LAST"{link: [Perl 6 Index Tablet]LAST phaser} {...} . . . . at loop termination time, after any LEAVE
> .
> "PRE"{link: [Perl 6 Index Tablet]PRE phaser} {...} . . . . . assert precondition at every block entry, before ENTER
> "POST"{link: [Perl 6 Index Tablet]POST phaser} {...} . . . . assert postcondition at every block exit, after LEAVE
> .
> "CATCH"{link: [Perl 6 Index Tablet]CATCH phaser} {...} . . . catch exceptions, before LEAVE
> "CONTROL"{link: [Perl 6 Index Tablet]CONTROL phaser} {...}. . catch control exceptions (like next/last/return etc), before LEAVE

^^^ Jump Commands

> "goto"{link: [Perl 6 Index Tablet]goto} . . . . jump to a named label
> "redo"{link: [Perl 6 Index Tablet]redo} . . . . repeat this loop turn
> "next"{link: [Perl 6 Index Tablet]next} . . . . skip to the next loop turn
> "last"{link: [Perl 6 Index Tablet]last}. . . . . leave this loop now
> "break"{link: [Perl 6 Index Tablet]break}. . . . leave this when clause
> "leave"{link: [Perl 6 Index Tablet]leave}. . . . leave this block with a return value
> "return"{link: [Perl 6 Index Tablet]return} . . . leave this routine with a return value

^^^ Conditionals

> "if"{link: [Perl 6 Index Tablet]if} . . . . . . when following expression evals in boolean context to True, the block that following after that will be executed
> "elsif"{link: [Perl 6 Index Tablet]elsif} . . . . works like if, but only recognized if no preceding "if" or "elsif" clause was executed
> "else"{link: [Perl 6 Index Tablet]else} . . . . following block will be executed, when no preceding "if" or "elsif" clause was executed
> "unless"{link: [Perl 6 Index Tablet]unless}. . . opposite of if, no "elsif" or "else" is allowed to follow
> "given"{link: [Perl 6 Index Tablet]given} . . . evals an expression into scalar context assignes it to $_ for the following block
> "when"{link: [Perl 6 Index Tablet]when} . . . smartmatches an expression against $_; if the result is True, the following block will be executed
> "default"{link: [Perl 6 Index Tablet]default} . . following block will be executed, when no "when" clause was executed

^^^ Loops

> "loop"{link: [Perl 6 Index Tablet]loop} . . . . general (endless) loop, unless used as an C-style-loop, evals following expression into void context
> "repeat"{link: [Perl 6 Index Tablet]repeat}. . . initial command for while or until loops that have their condtion at the end
> "while"{link: [Perl 6 Index Tablet]while}. . . . loop with negative exit condition (exit when False), condition, evals expression into boolean context
> "until"{link: [Perl 6 Index Tablet]until} . . . . loop with positive exit condition(exit when True), evals expression into boolean context
> "for"{link: [Perl 6 Index Tablet]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),

^^^ Routines

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

^^^^ Routine Types

> "sub"{link: [Perl 6 Index Tablet]sub}. . . . . . . . normal routine, named block with parmeters
> "method"{link: [Perl 6 Index Tablet]method} . . . . . inheritable object methods
> "submethod"{link: [Perl 6 Index Tablet]submethod}. . . not inheritable methods
> "regex"{link: [Perl 6 Index Tablet]regex} . . . . . . routine that executes a regular expression
> "rule"{link: [Perl 6 Index Tablet]rule} . . . . . . . alias to regex :ratchet :sigspace
> "token"{link: [Perl 6 Index Tablet]token} . . . . . . alias to regex :ratchet
> "macro"{link: [Perl 6 Index Tablet]macro}. . . . . . routine that is compiled to an AST at BEGIN (ASAP, compile time)
> "quasi"{link: [Perl 6 Index Tablet]quasi} . . . . . . block that is compiled to an AST at runtime

^^^^ Routine Modifier

> "multi"{link: [Perl 6 Index Tablet]multi routine modifier}. . . . . marks routines, witch can have siblings with same name but different signature; when called, the one with matching sig is executed
> "only"{link: [Perl 6 Index Tablet]only routine modifier} . . . . . routines which dont' allow to have an multi sibling (is default, you may leave it out)
> "proto"{link: [Perl 6 Index Tablet]proto routine modifier}. . . . . fallback for multi, if no multi signature matches the caller, a proto with same name is executed

^^^^ Routine Traits

"phasers"{link: Closure Traits} (closure traits) can also be seen as routine traits

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

^^^^ Parameter Traits

> "as"{link: [Perl 6 Index Tablet]as parameter trait} . . . . . . . data coming through that parameter will be coerced to the type following *as*
> "readonly"{link: [Perl 6 Index Tablet]readonly parameter trait} . . . immutable parameter
> "rw"{link: [Perl 6 Index Tablet]rw parameter trait} . . . . . . . mutable parameter (rw stands for: read write)
> "copy"{link: [Perl 6 Index Tablet]copy parameter trait}. . . . . . read-writable copy of the original argument ("pass-by-value")
> "dynamic"{link: [Perl 6 Index Tablet]dynamic parameter trait} . . . parameter is an "environmental" variable, a lexical in the dynamic scope
> "parcel"{link: [Perl 6 Index Tablet]parcel parameter trait}. . . . . raw reference, will not be contextualized

^^^^ Signature Symbols

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

> "!"{link: [Perl 6 Index Tablet]exclamation mark signature} . . . . . suffix of required parameter (default when named, not positional)
> "*"{link: [Perl 6 Index Tablet]asterisk signature} . . . . . prefix of slurpy arrays
> -->. . . . "prefix of return type"{link: [Perl 6 Index Tablet]minus minus greater signature} (couldn't link the arrow due wiki syntax)
> "->"{link: [Perl 6 Index Tablet]minus greater signature} . . . . prefix of named readonly parameters for a block (pointy block syntax)
> ":"{link: [Perl 6 Index Tablet]colon signature} . . . . . prefix of named parameter, positional when without
> "::"{link: [Perl 6 Index Tablet]colon colon signature}. . . . . prefix of a variable type introduced in a signature
> "<->"{link: [Perl 6 Index Tablet]lower minus greater signature} . . . prefix of named writeable parameters for a block (double pointy block syntax)
> "?"{link: [Perl 6 Index Tablet]question mark signature} . . . . . suffix of optional parameter (default when positional, not named)
> "^"{link: [Perl 6 Index Tablet]caret signature}. . . . . prefix of metaclass methods, _$obj.^methods();_ is shortcut for _"$obj.HOW.methods($obj);"{link: Object Introspection}_

^^^^ Callframe Methods

> args . . . . .
> callframe. .
> caller . . . .
> file. . . . . .
> hints. . . . .
> inline . . . .
> leave . . . .
> line. . . . . .
> my . . . . . .
> package. . .

----

"Overview"[Perl 6 Tablets] - _Chapter:_ "0:History"[Perl 6 History Tablet], "1:Design"[Perl 6 Language Design Tablet], "2:Basics"[Perl 6 Basics Tablet], "3:Var"[Perl 6 Variable Tablet], "4:Op"[Perl 6 Operator Tablet], "5:IO"[Perl 6 IO Tablet], "6:{}"[Perl 6 Block Tablet], "7:Sub"[Perl 6 Subroutine Tablet], "8:OOP"[Perl 6 OOP Tablet], "9:Rx"[Perl 6 Regex Tablet], "10:Meta"[Perl 6 Meta Tablet]
"Intro"[Perl 6 Intro Tablet] - _Appendices:_ "A:Index"[Perl 6 Index Tablet], *"B:Tables"[Perl 6 Lookup Tablet]*, "C:Cook"[Perl 6 Cookbook Tablet], "D:Delta"[Perl 6 Delta Tablet], "E:Best of"[Best Of Perl 6 Tablet], "F:Links"[Perl 6 Links Tablet]

----


Upload Files

Click "Browse" to find the file you want to upload. When you click "Upload file" your file will be uploaded and added to the list of attachments for this page.

Maximum file size: 50MB

 
 
 
File Name Author Date Uploaded Size

Save Page As

Enter a meaningful and distinctive title for your page.

Page Title:

Tip: You'll be able to find this page later by using the title you choose.

Page Already Exists

There is already a page named XXX. Would you like to:

Save with a different name:

Save the page with the name "XXX"

Append your text to the bottom of the existing page named: "XXX"

Upload Files

Click "Browse" to find the file you want to upload. When you click "Add file" this file will be added to the list of attachments for this page, and uploaded when you save the page.

 
 
 
Add Tags

Enter a tag and click "Add tag". The tag will be saved when you save the page.

Tag: 

Suggestions: