Perl 6
Perl 6 Basics Tablet: Revision 9
"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: }

_1st law of language redesign: Everyone wants the colon for their particular syntax._
_2nd law of language redesign: Larry gets the colon for whatever he wants._

Basics doesn't mean here easy but fundamental. Which mostly translates to how to format and reformat data (numbers, strings and more).

^ Defaults

Please note that any Perl 6 source code is treated as unicode by default. Also _use strict;_ and _use warnings;_ are enabled implicitly.

^ Statements

Unless you use "blocks"[Perl 6 Block Tablet], a Perl program executes one statement after another in linear progression. They have to be separated by a semicolon (*;*), except before and after a closing curly brace, where it is optional.

^ Spaces and Indentation

Perl doesn't care about indentation. And spaces are still in many places without meaning. However these have become fewer.

^ Comments

^^ Single Line

Like in Perl 5 and many other languages of its league a "#" tells the compiler to ignore the rest of the line.

^^ Multi Line

> #`( )

> =begin comment
> =end comment

^^ POD

^ Number Literals

Konverting into numerical context means still: take from left to right all digits and other characters, up to the first char that clearly don't belong to a number definition and stop there.

A single underscore is allowed only between any two digits in a literal number, like:

> $people = 3_456_789; # same as 3456789

^^ Radix Prefixes

> 0b binary - base 2, digits 0..1
> 0o ocatal - base 8, digits 0..7
> 0d decimal - base 10, digits 0..9
> 0x hexadecimal - base 16, digits 0..9,a..f (case insensitive)

^^ General Radix Form

> :10<42> # same as 0d42 or 42

^^ Scientific Notation

> $float = 60.2e23 # becomes automatically 6.02e24
> $float = 6.02E-23 # capital E works too

^^ Rational Number

To distinguish them from a division operation, you have to groupe them with braces.

> (3/7)
> (3/7).numerator
> (3/7).denominator
> (3/7).nude.perl

As always, *.perl* gives you a almost like source code formatting which results here in "3/7". Adding *.nude* you get "(3/7)", the nude source code.

^^ Complex Number

> -3-6.02E-23i

^^ Version Number

^ Quoting

> Q /.../;

^^ Quote Words

> qw/.../
> <...>
> Q :w /.../;
> Q :words /.../;

> <<>>
> Q :ww /.../;
> Q :quotewords /.../;

^^ Single Quotes

> ''
> Q :q /.../;
> Q :double /.../;

^^ Double Quotes

> ""
> Q :q /.../;
> Q :double /.../;
> Q :s, :a, :h, :f, :c, :b /.../;

^^ Heredocs

Are now normal quoted strings, only with a special delimiter.

> Q :to 'EOT';
> ...
> ...
> EOT

To make templates in which variables and closures are evaluated, take the normal double quote and just add the adverb for the heredoc delimiter or define with other adverbs what exactly you want to have evaluated.

> pp:to 'EOT';
> EOT

^^ Paths

^^ Code

^^ Regex

^ Formating

^^ perl

The .perl method is a built in Data::Dumper (pretty printer) which gives you structured data the way you write it in perl source code.

^^ fmt

^^ sprintf

^^ pack

^^ Formats

----

"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: