Quick jump:  What's new

 
Go to:
 
Weblog: Recent Changes 
in Perl 6
WITCH hack

Mnemonics

"backslash", "escape", "hack"

    • used to "back out" of a syntax to a character's original meaning
    • used to "hack" around, or "escape", special characters

When used inside a regular expression

\ in front of any character will change it from a metacharacter to a literal, or visa versa.

When used in a Signature

\ before a sigilless name is a parcel binding.
\ before a sigilled parameter prevents parcel collapse.

Operators containing this character

Modifying a reduction operator such as [\+] (modification of [+]) creates a lazy feed of intermediary results..

Other Uses

unary \ as a noun in front of an argument or arguments creates a Capture
\ in front of whitespace creates an unspace which is used to jam spaces in where they don't belong.
\o \c \x and \d used inside an interpolated string introduce literal characters

permalink
Perl 6 Tablets

These are the Perl 6 Tablets, a comprehensive manual, aimed to support many different ways of learning. The content is nicely sorted and indexed and many links allow you to follow your interest freely. For a lightweight introduction, try the Perl 6 Tutorial. If its too easy, read the specs.


DISCLAIMER: This docs moved to tablets.perl6.org/ and no longer represent the current state.
Maybe this will vanish soon!


Preface and Introduction

Tablet 0: History

Tablet 1: Language Design

Tablet 2: Basic Syntax (Spaces, Comments, Literals, Quoting, Formatting)

Tablet 3: Variables (Sigils, Twigils, Assignment, Typing, Scopes)

Tablet 4: Operators (Comparison, Math, String, Logic, Metaops)

Tablet 5: IO (Command Line, Files, Sockets, Network, Misc.)

Tablet 6: Blocks (Conditions, Loops)

Tablet 7: Subroutines (Signatures, Modules)

Tablet 8: Objects (Classes, Roles)

Tablet 9: Regex (Rules, Grammars)

Tablet 10: Metaprogramming (Macros, DSL)


Appendix A: Index (all ops, builtins, methods and it terms, alphabetically ordered)

Appendix B: Tables, short reference (cheat sheets ans summary tables)

Appendix C: Cookbook (chunks of everyday Perl 5, translated into idiomatic Perl 6)

Appendix D: Perl 5-6 Delta

Appendix E: Exellence, Appetizer, best of tour

Appendix F: Links

Appendix G: Glossary

permalink
Perl 6 People


This "who is doing what" and "who is interested in what" social-networking page is for anyone (including newbies and organizations) doing anything significant (including commercial) regarding Perl 6. Intructions about how to expand are at the end. Not all links lead to articles in this wiki. To get all of them click on the "People" tag on the right side or on this link.


Donors, Sponsors, and Supporters

This important section expanded enough to get its own page (Yea!): Perl 6 Donors, Sponsors, and Supporters.

The Language Design Team

Also known as "@Larry", and led by Larry Wall, our hero and leader, the inventor of Perl. We think he deserves a MacArthur prize.

Software Developers

Contributors to Implementations

Developers using Perl 6 (and Parrot)

  • Darren Duncan: DB-related stuff.
  • Stevan Little: "Moose is the new Perl" Moose meta-object system. Stevan's journal.
  • Carl Mäsak: frenetic Rakudo user, November author and our number one bug finder
  • Mark Stosberg: I'm working on porting CGI::Application to Perl 6 and having fun along the way.

Documentation Authors

Books

Wiki Contributors

Article Authors

Others

  • Ask Bjørn Hansen: Set up Perl 6 newsgroups (http://www.nntp.perl.org/group)
  • Andy Lester: Started and maintains Perlbuzz, which reports frequently about Perl 6 related events.
  • Gabor Szabo: gives talks and organizes a lot of different things in the community
  • Juerd Waalboer: Runs feather, a Perl 6 development machine, and used to be active in several areas of Perl 6/Pugs.

The Old Guard

These individuals contributed a great deal, but are no longer serving in their former capacities:

  • Bernhard Schmalhofer: Worked on Pipp, PHP on Parrot, and Eclectus, Scheme on Parrot.
  • Piers Cawley: Former parrot/perl6 summarizer.
  • Simon Cozens: Former parrot pumpking (versions 0.0.1 through 0.0.4), Parrot' name is based on his joke.
  • Matt Fowles: Former parrot/perl6 summarizer.
  • Ann Barcomb: Former parrot/perl6 summarizer.
  • Steve Fink: Former parrot pumpking (versions 0.0.9 through 0.0.12).
  • Jeff Goff: Former parrot pumpking (versions 0.0.5 to 0.0.8).
  • Luke Palmer: Former Perl 6 language list monitor and co-author of the retroactive Synopses.
  • Chip Salzenberg: Former parrot pumpking and the parrot architect, and a large contributor.
  • Dan Sugalski: Former and initial parrot architect and developer.
  • Leopold Tötsch: Leo was the pumpking for releases 0.0.13 - 0.4.5, and for some time was a larger contributor. Also see "People of Perl: Leopold Toetsch".
  • Nathan Torkington: Former project manager emeritus.
  • Jesse Vincent: The former Perl 6 project manager. An expert at the "stick and carrot" approach to open source development. ("Blog"<http://use.perl.org/~jesse)
  • Bryan Warnock: Used to compile the Perl 6 Digest with Simon Cozens. Yes, that Warnock.

How to add yourself to this page:

  • Add your (or their) name below, in alphabetical order (by last name or organization), in the most relevant section (or sections). Create a new section if a suitable section doesn't exist.
  • Link the name to a suitable home page, blog, or whatever, or you can create a new personal page on this wiki to link to (use the same name for the page name).
  • Add a few sentences relevant activities, interests, and so on.
permalink
Perl 6 Glossary Tablet

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


A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | T | U | V | W | X | Y | Z

  • ALAP - as late as possible, within a given execution phase (compile time or run time)
  • ASAP - as soon as possible, within a given execution phase (compile time or run time)
  • AST - (abstract syntax tree), tree like data structure, in which source code is transformed, before running the programm
  • backtracking - after a part of a pattern didn't match, this last operation might not be counted (undone) and the pointer for the position in the string where actual matching is taking place is going a few steps to the left (it goes back)
  • binding - making two variables share the same content by pointing to same memory location
  • block - syntactically just a piece of code inside curly brackets ({}), when evaluated it becomes an object of the type Block
  • closure - routines whose state (content of all local variables) is completely preserved until the next execution, mostly used as a fancy alias for a block
  • coderef - reference (pointer) to an executable block of code (routine)
  • compilation - reading the human written source code and make it an executable (piece of) program
  • compile time - time when Perl converts source code to executable form (bytecode), is always before runtime even if code can be compiled via eval and evalfile when the program is already runnung, to run code at the begin of compile time use BEGIN and CHECK to run at the end of compile time for that unit (mostly the file or the to be evaled string)
  • context - when executing a function or operator Perl considers the expression from which the call was to return a scalar or other kind of result
  • context variable - name for $_, which is used by built in Perl functions as an implicit parameter and as memory of the last result
  • currying - creating a subroutine that calls another with certain parameter to be predefined
  • declarative programming - programming paradigm that expresses the logic of a computation without describing its control flow
  • design by contract - programming style in which parameters and return values from routines must meet conditions; A signature is considered contract in Perl 6
  • evaluation - executing a piece of program, before that all variables will be replaced with their content
  • iteration - flow control, repeatedly executing a block
  • junction - a type of value that holds a logical combination of several values, example: (A and B) or C
  • list context -
  • longest token matching - (short LTM) when searching a pattern with alternatives (sub|substr) the search will continue after finding the pattern 'sub' because of looking for the longest alternative
  • object oriented programming - (short oop) programming paradigm (style), that arranges data and functions that belong together into so called objects
  • parameter - value passed to a method or subroutine, mostly as part of the signature
  • parsetree - hierarchical data representing the logical structure of a program, also called AST
  • pipe - connection between 2 processes, move data (mostly only in one direction) without buffering
  • POD - Plain Old Documentation, a markup language to be embeded into Perl source code, has in Perl 6 ability to store data to be retrieved later
  • pointy block - a block that is given parameters with ->
  • property - metadata of a variable set at runtime
  • reference - address of data in memory, often termed a Capture in Perl 6
  • regular expression - in Perl5: pattern matching notation, either regex, token or rule in Perl6
  • runtime - time when execution hits a certain part of the program, after compile time
  • scope - the block of code within which an identifier is usable
  • sigil - character that serves as a prefix to categorize the following name, most prominent in Perl are the variable sigils: $, @ and %
  • signature - function parameters (left-hand side of a binding), surrounded by round parentheses
  • slice - part of an array or list
  • slurpy array - array parameter that receives all (slurps) all optional subroutine arguments
  • topicalizer - every keyword that sets the $_ variable, eg given, for
  • trait - additional property of a variable, defined at compile time, see but, what other languages call trait Perl calls role
  • twigil - second(ary) sigil indicating a special property of a variable
  • yadda operator - placeholder for later to be written code, because in empty routines are forbidden, comes in 3 flavours: ..., ??? and !!!

A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z


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


permalink
Perl 6 Meta Tablet

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




Macros

Clean Macros

Dirty Macros

Operators

our &postfix:<²> := &infix:<**>.assuming(b => 2);

Changing Internal Grammar

DSL


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


permalink
Perl 6 Links Tablet

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




Project Pages

Downloads (sources, binaries):

CPAN:

  • Perl6::* modules backports of many Perl 6 features in Perl 5
  • Bundle::Perl6 Pakage of all Perl 6 related Module (except Moose :))
  • p6doc aka Perl6::Doc: a small command line viewer and many Perl 6 documents

Docs

Wikis:

more Info:

News:

IRC:


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


permalink
Perl 6 Regex Tablet

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




Larry Wall: We put the "Regular" back into "Expression".

Like quotes, are Regular Expressions now a sublanguage, a language inside the language, instead of being just funny strings. They are parsed by a completely different set of rules, which are stored in the special variable $~Regex ($~Trans for transliterations and $~P5Regex for compatible Regexes). But these rules are made much more consistant with the main language than before.

Literal Character

Every alphanumeric character has no special meaning and stand for the character visible. If a backslash (\) is standing directly in front of the character it becomes a metacharacter. For not alphanumeric chars the opposite is true. Inside of quotes every char is literal.

Metacharacter

table

Modifier

Operators

rx/.../ aka Q :regex /.../
m/.../ aka Q :match /.../
ms/.../ aka Q :match :sigspace /.../.../
s/.../.../ aka Q :subst /.../.../
ss/.../.../ aka Q :subst :samespace /.../.../
tr/.../.../ aka Q :trans /.../.../

Methods

comb
match
subst
trans

Special Variables

$/
$<..>
$()
$0 ..

Matching

Substitution

Transliteration

my $escaped = $html.trans(
[ '&', '<', '>' ] =>
[ '&amp;', '&lt;', '&gt;' ]
);

Grammars

Predefined Rules

Are listed here. <prior> is somehow an exception.

all slang variables


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


permalink
Perl 6 OOP Tablet

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 - Appendices: A:Index B:Tables C:Cook D:Delta E:Best of F:Links G:Glossary




Damian Conway: In order to understand how object orientation works in Perl, we first need to agree what object orientation actually is. And that's surprisingly hard to do. Object-oriented programming has been around for at least three decades now, and in that time many opinions, theories, and even ideologies have been formulated on the subject. Each has purported to definitively characterize object orientation. Most are mutually inconsistent. No two are exactly alike.

Classes

Attributes

Methods

Submethods

Inheritance

Delegation

Roles


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 - Appendices: A:Index B:Tables C:Cook D:Delta E:Best of F:Links G:Glossary


permalink
Best Of Perl 6 Tablet

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




This is a small tour, showing the best features and improvements of Perl 6 in short examples, compared to similar working Perl 5 examples.

Command Line

Making output will become simpler and easier for newbies.

               Perl 5                                     Perl 6 
 print "bananas are good\n";                     say "bananas are good";
 print "and I said: $quotes{\"me\"}\n";          say "and I said: %quotes{"me"}.";
 print "and I said: $quotes{\"me\"}\n";          say "and I said: %quotes<me>.";
 print "What is ... ";                           $result = prompt "What is ... ";
 chomp($result = <>);

File IO

File::Slurp is in the Perl 6 core language and file reading is simpler then ever (and autochomp included).

               Perl 5                                     Perl 6 
 $content = do { local $/;                       $content = slurp "poetry.txt";
    open my $FH, "poetry.txt"; <$FH>
 };

chomp(@content = do {                            @content = lines "poetry.txt";
    open my $FH, "poetry.txt"; <$FH>
});

Automatic multithreading

Applying operations to junctions and arrays is now syntactically compact and readable. Perl 6 will create threads where appropriate to use multiple processors, cores or hyperthreading for high level language SIMD concurrent processing.

               Perl 5                                     Perl 6 
 my $sum;                                        my $sum = [+] @numbers;
 $sum += $_ for @numbers;
 for (0 .. $#factor1) {                          @product = @factor1 >>*<< @factor2;
   $product[$] = $factor1[$] * $factor2[$_];
 }

The Perl 5 code is a simplification, of course Perl6 "does the right thing" when the arrays have different lengths.

Comparison

Here are junctions, then chained comparison operators.

               Perl 5                                     Perl 6 
 if ($a == 3 or $a == 4 or $a == 7) {...}        if $a = 3 | 4 | 7 {...}
 if (4 < $a and $a < 12) {...}                   if 4 < $a < 12 {...} 
 if (4 < $a and $a <= 12) {...}                  if $a ~~ 4^..12 {...}
 $a = defined $b ? $b : $c;                      $a = $b // $c;

The defined-OR operator eases lot of cases where Perl 5 newbies could fall into traps.

Case construct

               Perl 5                                      Perl 6 
                                                     given $a {
 if ($a == 2 or $a == 5) {...} }}                      when 2 | 5 {...}
 elsif ($a == 6 or $a == 7 or $a == 8 or $a == 9) {}   when 6 .. 9 {...} 
 elsif ($a =~ /g/) {...}                               when 'g' {...}
 else {...}                                            default {...}
                                                     }

That new construct (backported to 5.10) is clear to read, very versatile and when used in combination with junctions, becomes even clearer.

Powerful for loops

List iteration via for is now much more versatile.

               Perl 5                                     Perl 6 
 for my $i (0..15) {...}                         for ^16 -> $i {...}
 for (my $i=15; $i>1; $i-2) {...}                for 15,*-2...1 -> $i {...}
 for my $key (keys %hash) {                      for %hash.kv -> $key, $value {
   print "$key => $hash{$key}\n"; ...              say "$key => $value"; ...
 for my $i (0..$#a) {                            for zip(@a; @b; @c) -> $a, $b, $c {...}
   my $a = @a[$i];
   my $b = @b[$i];
   my $c = @c[$i]; ... 

Named parameters in subroutines

               Perl 5                                     Perl 6 
 sub routine {                                   sub routine ($a, $b, *@rest) {...}
   my $a = shift;
   my $b = shift;
   my @rest = @_;
 }

Objects with auto generated new and getters and setters

Simple Object creation is now as easy as it gets.

               Perl 5                                     Perl 6 
 package Heart::Gold;                            class Heart::Gold {
                                                   has $.speed;
 sub new {                                         method stop { $.speed = 0 }      
   bless {speed => 0 }, shift;                   }  
 }                                               
                                                 my Heart::Gold $hg1 .= new;
 sub speed {                                     $hg1.speed = 100;
   my $self = shift;                             my $hg2 = $hg1.clone;
   my $speed = shift;
   if (defined $speed) { $self->{speed} = $speed }
   else { $self->{speed} }
 }

 sub stop {
   my $self = shift; 
   $self->{speed} = 0;
 }

The new, getter, setter and clone methods are auto generated. Methods now are called "method".


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


permalink
Perl 6 Subroutine Tablet

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




Basics

sub

yadda

anonymous

pointy

return

Signatures

Positional Parameter

Named Parameter

Optional Parameter

Required Parameter

Multiple Dispatch

Currying

Wrapping

Namespaces

Scope

Package

Module

Class


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


permalink
Weblog Navigation
Loading...
Weblog Archives
  • Loading...

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: