Perl 6
Perl 6 Operator Tablet: Revision 34

Intro - Chapter: 0:History 1:Design 2:Basics 3:Var 4:Op 5:IO 6:Block 7:Sub 8:OOP 9:Rx 10:Meta
Overview - Appendix: A:Index B:Tables C:Cook D:Delta E:Best of F:Links G:Glossary




Perl folklore: Perl is an operator based language.

Perl 6 has a huge amount of operators, because they support 2 of the main design goals: they offer dense and readable code. 2 + 3 is certainly shorter and easier to understand then add(2,3), since pictograms can be picked up faster than words. (Fortran made his whole carrier on that). But because they are so many, they had to be sorted by a rule named huffman coding, which was applied here more than in any other part of the syntax.

To understand an operator you have to know his arity (how many parameters he takes - usually one (!) or two (+) ).

The precedence tells which operator to prefer in case of conflict, when no braces are used (round braces are only used for grouping and managing precedence). It allows 2 + 3 * 5 to return 17, not 25, which would upset your math teacher.

Behind that link is a table which also tells you also the associativity of every operator. This tells you after which rule to resolve precedence if one operator is used several times like in 2 * 3 * 7.

Comparison

Smartmatch

This is the most mighty (much more mighty than its backported Perl 5 twin) of all Perl 6 operators. It can be called the "compare-this-with-that-operator". If the left side of that infix op matches somehow the content of the right side, it returns Bool::True, otherwise Bool::False. The negated form !~ naturally works the other way around. The exact comparison operation depends on the data types of the values on both sides. Just look into that large table to check your specific case.

Smartmatching was originally invented to make matching with regex semantically sane.

~~ !~

Equality

eqv eq == ===
!= !==

Traversing Sequence

++ -- succ pred

sequence generation

Generic Comparison

before after cmp

Numerical Comparison

< == > <=> <= >=

String Comparison

lt eq gt leg le ge

joined comparison

3 < $a == $a < 7

is not the same as

3 < $a < 7

because latter is evaled at once and the first in 2 steps (left to right)

Junctions

| & ^ !
any all one none

Ranges

.. ^

logical selection

&& - and
|| - or
// - err
^^ - xor

see also numerical selection

ternary

?? !!

flipflop

ff fff

file test

table

yadda

...
???
!!!

context forcing scalar ops

bool context

? !
?& ?| ?^

numeric context

+ - * ** / % %%
+& +| +^ +< +>
mod exp sqrt sin cos tan log log10

numerical selection

min max minmax

String context

~ x
~& ~| ~^ ~< ~>

Ops for arrays/lists

List generation

The simplest way to create a list is by repeating some values:

'munch' xx 3 # results in 'munch', 'munch', 'munch'
('hallo', 'echo') xx 2 --> 'hallo', 'echo', 'hallo', 'echo'

In list context the range operator produces lists:

@ 2 .. 7 --> 2,3,4,5,6,7

Sequence Operator

...

traversing sequence

Zip

Z

Combinators

X

Hyperops

<< >>

Reduce

[ ]

Triangle

[\ ]

Feed Ops

<== ==>
<<== ==>>

Assignment ops

self assigning ops

precedence table

is in Appendix B

intentionally not existing ops

making own operators


Intro - Chapter: 0:History 1:Design 2:Basics 3:Var 4:Op 5:IO 6:Block 7:Sub 8:OOP 9:Rx 10:Meta
Overview - Appendix: A:Index B:Tables C:Cook D:Delta E:Best of F:Links G:Glossary



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: