Perl 6
Perl Lookup Table: Revision 17
Index - Chapter 0:Intr, 1:Hist, 2:Design, 3:Var, 4:Op, 5:IO, 6:{}, 7:Sub, 8:OOP, 9:Rx - Appendix A:Index, B:Tables, C:Best of, D:Delta, E:Links
Variables
Twigils
, or secundary sigils. They follow after a $ (scalar), @ (array) or % (hash), and mark special namespaces or variables with special meaning and properties.
$foo . . . ordinary scoping
$.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> . .match variable, short for $/{'foo'}
$~foo . . .the foo sublanguage seen by the parser at this lexical spot
Special Variables
$/ . . . . . . . . . last created match object of this block
$<...> . . . . . . alias to named capture
$0 .. $9 . . . . . alias to positional capture (like in P5)
@(). . . . . . . . array that holds $0 .. $9 and rest and positional submatches
$! . . . . . . . . . error msg
-
$*ARGS . . . . . Arguments (Parameter) to a program (script), formerly @ARGV
$*IN . . . . . . . standard input handle (command line mostly)
$*OUT. . . . . . standard output (command line mostly)
$*ERR . . . . . . standard error output (command line mostly)
$*PERL . . . . . perl version running under
@*INC. . . . . . include pathes (but not for std library modules), formerly @INC
$*KERNEL. . . . operating system 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_WARN . . , formerly $SIG{__WARN__}
$*ON_DIE . . . . , formerly $SIG{__DIE__}
%*ENV . . . . . . , formerly %ENV
$*CWD . . . Str . . current working directory
$*COMPILING . . . .
$*DEBUGGING . . . .
-
$?KERNEL . . . . for which operating System was this program compiled?
$?PERL . . . . . . SoftwarePackage # Which Perl am I compiled for?, $?PERL.version for formerly $^V $]
$?CLASS. . . . . current class
@?BLOCK . . . . reference to current block
$?LINE . . . . . . current line number
-
@=COMMENT . All the comment blocks in the file
$=DATA. . . . . data block handle (=begin DATA ... =end)
@=DATA . . . . Same as above, but array
-
$~MAIN . . . the current main language (e.g. Perl statements)
$~Q . . . . . .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
Object Types
Any scalar variable (arrays and hashes are just collections of scalars) can hold any type of data. Nevertheless Perl know for many data types specific objects (known as data types) that can handle them.
Bit . . . . . Perl single bit (allows traits, aliasing, undef, etc.)
Int . . . . . Perl integer (allows Inf/NaN, arbitrary precision, etc.)
Str . . . . . Perl string (finite sequence of Unicode characters)
Num . . . . Perl number
Complex . .Perl complex number
Bool . . . . Perl boolean
Exception . Perl exception
Code . . . . Base class for all executable objects
Block . . . . Executable objects that have lexical scopes
List . . . . . Lazy Perl list (composed of immutables and iterators)
Seq . . . . . Completely evaluated (hence immutable) sequence
Range . . . A pair of Ordered endpoints; gens immutables when iterated
Set . . . . . Unordered collection of values that allows no duplicates
Bag . . . . . Unordered collection of values that allows duplicates
Junction . . Set with additional behaviors
Pair . . . . . A single key-to-value association
Mapping . . Set of Pairs with no duplicate keys
Signature . .Function parameters (left-hand side of a binding)
Capture . . .Function call arguments (right-hand side of a binding)
Blob . . . . . An undifferentiated mass of bits
low level data types
This is more low level then alst table. These types are more ment 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)
uint1 (aka bit)
uint2
uint4
uint8 (aka byte)
uint16
uint32
uint64
num32
num64 (aka num on most architectures)
num128
complex32
complex64 (aka complex on most architectures)
complex128
Str
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
L . Additive . . . . . . . . + - +| +^ ~| ~^ ?| ?^
L . Replication. . . . . . . x xx
X . Concatenation . . . . ~
X . Junctive and . . . . . & also
X . Junctive or . . . . . . | ^
L . Named unary . . . . . sleep abs sin temp let
N . Nonchaining 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 . . . . . . true not
X . Comma operator . . . , p5=> :
X . List infix. . . . . . . . . Z minmax X X~ X* Xeqv ...
R . List prefix. . . . . . . . print push say die map substr ... + * any $ @
X . Loose and . . . . . . . and andthen
X . Loose or . . . . . . . . or xor orelse
X . Sequencer. . . . . . . <==, ==>, <<==, ==>>
N . Terminator. . . . . . . ; {...}, unless, extra ), ], }
File Teste Ops
:r . . . file is readable by effective uid/gid.
:w. . . file is beschreibbar by effective uid/gid.
:x . . . file is ausführbar by effective uid/gid.
:o . . . file is owned by effective uid.
.
:R . . . file is readable by real uid/gid.
:W . . . file is writable by real uid/gid.
:X . . . file is executable by real uid/gid.
:O . . . file is owned by real uid.
.
:e . . . file exist
:z . . . file has Größe gleich 0 (ist leer).
:s . . . file has Größe größer 0 (gibt Größe in Bytes zurück)
.
:f . . . file is a plain file.
:d . . . file is a directory.
:l . . . file is a symbolic link.
:p . . . file ist 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.
.
:T . . . file ist eine ASCII text Datei (heuristische Vermutung).
:B . . . file ist eine "Binärdatei" (Gegenteil von :T).
.
:M . . . Script start time minus file modification time, in days.
:A . . . Same for access time.
:C . . . Same for inode change time (Unix, may differ for other platforms)
They stay mostly before a regular operator and give them different meaning or greate range.
In the example V stands vor Value L for left Value and R for right. A numer is the array index.
<op>= . . . self assign . . . known from P5, <var1> =<op> <var2> equals <var1> = <var1> <op> <var2>
>><op> . . hyper . . . verarbeitet parallel Arrays oder wendet einzelnen Wert auf Array an; @E = L1 op R1, L2 op R2, ...;
<<<op> . . hyper . . . verarbeitet parallel Arrays oder wendet einzelnen Wert auf Array an; @E = L1 op R1, L2 op R2, ...;<br />
[<op>]. . . reduction . . wendet den Op auf einen Array von Werten an; $Ergebnis = V1 op V2 op ...;<br />
[\<op>] . . reduction . . . wendet den Op auf einen Array von Werten an; @E = W1, W1 op W2, W1 op W2 op W3, ...;<br />
R<op> . . . reverse . . . vertauscht Operatoren<br />
X<op> . . . combinator . . .wendet op auf alle Paare eines Kartesischen Prokuktes an; @E = L1 op R1, L1 op R2, L2 op R1, }}
Unicode operators
The 2 Hyperoperators can be written with the UTFsigns "chevron" or with 2 lower that or greater than signs.
« aka <<
» aka >>
Smartmatch
Text Processing
Escape Sequence
Or also called control chars.
\a . . . . . . . . BELL
\b . . . . . . . . BACKSPACE
\e . . . . . . . . ESCAPE
\f . . . . . . . . FORM FEED
\n . . . . . . . . LINE FEED
\r . . . . . . . . CARRIAGE RETURN
\t . . . . . . . . TAB
Rule primitvs
\0[ . . . ] Match a character given in octal (brackets optional).
\b Match a word boundary.
\B Match when not on a word boundary.
\c[ . . . ] Match a named character or control character.
\C[ . . . ] Match any character except the bracketed named or control character.
\d Match a digit.
\D Match a nondigit.
\e Match an escape character.
\E Match anything but an escape character.
\f Match the form feed character.
\F Match anything but a form feed.
\n Match a (logical) newline.
\N Match anything but a (logical) newline.
\h Match horizontal whitespace.
\H Match anything but horizontal whitespace.
\L[ . . . ] Everything within the brackets is lowercase.
\Q[ . . . ] All metacharacters within the brackets match as literal characters.
\r Match a return.
\R Match anything but a return.
\s Match any whitespace character.
\S Match anything but whitespace.
\t Match a tab.
\T Match anything but a tab.
\U[ . . . ] Everything within the brackets is uppercase.
\v Match vertical whitespace.
\V Match anything but vertical whitespace.
\w Match a word character (Unicode alphanumeric plus "_").
\W Match anything but a word character.
\x[ . . . ] Match a character given in hexadecimal (brackets optional).
\X[ . . . ] Match anything but the character given in hexadecimal (brackets optional).
Flow Control
Closure Traits
in every block can be inserted several special named blocks that are started at certain times. Because they are treated as part of a block object, they are called traits. Those marked with a * can also be used within an expression.
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
START {...}* on first ever execution, once per closure clone
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, before LEAVE
Index - Chapter 0:Intr, 1:Hist, 2:Design, 3:Var, 4:Op, 5:IO, 6:{}, 7:Sub, 8:OOP, 9:Rx - Appendix A:Index, B:Tables, C:Best of, D:Delta, E:Links
|